Skip to content

Commit

Permalink
Bug fix and various improvements (#1571)
Browse files Browse the repository at this point in the history
* BUG: label_vertebrae: Updated label disc value (fixes #1570)

* REF: fixed typo

* OPT: label_vertebrae: Added instructions above image for sagittal dialog (fixes #1563)
  • Loading branch information
jcohenadad authored and peristeri committed Jan 17, 2018
1 parent 4148d34 commit 4b14a2d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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
1 change: 1 addition & 0 deletions spinalcordtoolbox/gui/sagittal.py
Expand Up @@ -55,6 +55,7 @@ def _init_canvas(self, parent):
vlayout.addWidget(self.axial)

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

0 comments on commit 4b14a2d

Please sign in to comment.