Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix and various improvements #1571

Merged
merged 3 commits into from Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/sct_label_vertebrae.py
Expand Up @@ -434,6 +434,7 @@ def vertebral_detection(fname, fname_seg, contrast, param, init_disc, verbose=1,
# define mean distance (in voxel) between adjacent discs: [C1/C2 -> C2/C3], [C2/C3 -> C4/C5], ..., [L1/L2 -> L2/L3]
centerline_level = data_disc_template[xct, yct, :]
# attribute value to each disc. Starts from max level, then decrease.
# NB: value 2 means disc C2/C3 (and so on and so forth).
min_level = centerline_level[centerline_level.nonzero()].min()
max_level = centerline_level[centerline_level.nonzero()].max()
list_disc_value_template = range(min_level, max_level)
Expand Down Expand Up @@ -469,15 +470,16 @@ def vertebral_detection(fname, fname_seg, contrast, param, init_disc, verbose=1,
params = AnatomicalParams()
params.num_points = 1
params.vertebraes = [3, ]
params.subtitle = 'Click at the posterior tip of C2-C3 disc'
input_file = Image(fname)
output_file = input_file.copy()
output_file.data *= 0
output_file.setFileName(os.path.join(path_output, 'labels.nii.gz'))
controller = launch_sagittal_dialog(input_file, output_file, params)
mask_points = controller.as_string()

# assign new init_disc_z value, which corresponds to the first vector of mask_points. Note, we need to substract from nz due to SAL orientation: in the viewer, orientation is S-I while in this code, it is I-S.
init_disc = [nz - int(mask_points.split(',')[0]), 2]
# assign new init_disc_z value
# Note: there is a discrepancy between the label value (3) and the disc value (2). As of mid-2017, the SCT convention for disc C2-C3 is value=3. Before that it was value=2.
init_disc = [int(mask_points.split(',')[2]), 2]

# display init disc
if verbose == 2:
Expand Down
3 changes: 2 additions & 1 deletion spinalcordtoolbox/gui/base.py
Expand Up @@ -45,7 +45,8 @@ def __init__(self,
self.start_vertebrae = 50
self.end_vertebrae = -1
self.num_points = 0
self._title = ''
self._title = '' # figure title
self.subtitle = '' # subplot title (will be displayed above the image)
self._vertebraes = []
self.input_file_name = ""
self.starting_slice = 0
Expand Down
2 changes: 1 addition & 1 deletion spinalcordtoolbox/gui/centerline.py
Expand Up @@ -54,7 +54,7 @@ def skip_slice(self):

def select_point(self, x, y, z):
if self.mode == 'CUSTOM' and not self._slice:
raise InvalidActionWarning('Select a saggital slice before selecting a point.')
raise InvalidActionWarning('Select a sagittal slice before selecting a point.')
x = self._slice
if not self.valid_point(x, y, z):
raise ValueError('Invalid point selected {}'.format((x, y, z)))
Expand Down
1 change: 1 addition & 0 deletions spinalcordtoolbox/gui/sagittal.py
Expand Up @@ -49,6 +49,7 @@ def _init_canvas(self, parent):
layout.addWidget(self.labels)

self.sagittal = widgets.SagittalCanvas(self, plot_points=True, annotate=True)
self.sagittal.title(self.params.subtitle)
self.sagittal.point_selected_signal.connect(self.on_select_point)
layout.addWidget(self.sagittal)

Expand Down