• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SciKit-Surgery / scikit-surgerycore / 12535506235

29 Dec 2024 12:45PM UTC coverage: 98.125% (-0.08%) from 98.203%
12535506235

push

github

MattClarkson
Merge branch '75-load-slicer-points'

26 of 27 new or added lines in 1 file covered. (96.3%)

628 of 640 relevant lines covered (98.13%)

14.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.43
/sksurgerycore/io/load_slicer_points.py
1
# -*- coding: utf-8 -*-
2

3
""" Functions to load 3D Slicer's landmarks, saved as .json or .mrk.json """
3✔
4

5
import json
15✔
6
import numpy as np
15✔
7
import sksurgerycore.utilities.file_utilities as fu
15✔
8
import sksurgerycore.utilities.validate_file as f
15✔
9

10

11
def load_slicer_pointset(file_name):
15✔
12
    """
13
    Load a 3D Slicer's pointset file from .mrk.json or .json.
14

15
    :param file_name: string representing file path.
16
    :return: ids (length N), points (Nx3)
17
    """
18
    abs_file = fu.get_absolute_path_of_file(file_name)
15✔
19
    f.validate_is_file(abs_file)
15✔
20

21
    file_data = None
15✔
22
    with open(abs_file, "r", encoding='utf-8') as read_file:
15✔
23
        file_data = json.load(read_file)
15✔
24

25
    if file_data is None:
15✔
NEW
26
        raise IOError(f"Failed to read data from {abs_file}")
×
27

28
    ids = []
15✔
29
    points = []
15✔
30
    counter = 0
15✔
31
    list_of_markups = file_data["markups"]
15✔
32
    for markup in list_of_markups:
15✔
33
        control_points = markup['controlPoints']
15✔
34
        for control_point in control_points:
15✔
35
            point = control_point['position']
15✔
36
            ids.append(counter)
15✔
37
            points.append(point)
15✔
38
            print(f"Point id={counter}, position={point}")
15✔
39
            counter += 1
15✔
40
    result = np.array(points)
15✔
41
    ids = np.array(ids)
15✔
42
    return ids, result
15✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc