Spinalcordtoolbox: Add the OptiC method for improved spinal cord detection

Created on 12 Apr 2017  路  20Comments  路  Source: spinalcordtoolbox/spinalcordtoolbox

  • [x] replace centerline detection with optic in propseg (Ben)
  • [x] package binary
  • [x] change name dmri_model.yml for dwi_model.yml (Julien)
  • [x] test optic call with sh/tcsh env (to make sure FSLOUTPUTTYPE is properly passed)
feature sct_propseg

Most helpful comment

Works on OSX now.

All 20 comments

Model generated for each contrast (t1, t2, t2s and dmri).

Available under /Public_JCA/temp/charley/models/

I've create the branch issue1249. In this branch, I integrated OptiC into PropSeg, without the use of a wrapper. It is a first step for creating a wrapper for OptiC that would be called by PropSeg.

Link to PropSeg in new branch: https://github.com/neuropoly/spinalcordtoolbox/blob/issue1249/scripts/sct_propseg.py

Before testing it, we need to:

  • put the binaries into bin/
  • put the models into data/models/

MacOs Binaries available under /Public_JCA/temp/charley/mac/10_7/ and /Public_JCA/temp/charley/mac/10_11/

does version 10_7 work for all >10.7 osx?
if so, any advantage in copying 10_11?

i've updated uploaded binaries on OSF and updated the branch for the install part. Please update your local installation to reflect changes:
~
./install_sct -m
~

I have tested 10_7 on my machine (El Capitan, 10.11.5): it works well!
I do not see advantage to use 10_11

Unix binary of isct_spine_detect seems to use FSL:

django:t1 bedelb$ isct_spine_detect -ctype=dpdt -lambda=1.0 "/Users/bedelb/code/spinalcordtoolbox/data/models/t1_model.yml" "t1_int16_RPI_imghdr" "t1_int16_RPI_imghdr_optic"
ERROR:: Environment variable FSLOUTPUTTYPE is not set!
Please make sure that the appropriate configuration file is sourced by your shell (e.g. by putting it in .profile).
e.g. bash or sh users add the line ". ${FSLDIR}/etc/fslconf/fsl.sh"
e.g. tcsh or csh users add the line "source ${FSLDIR}/etc/fslconf/fsl.csh"

Here are the results for sct_testing/large:

T1-weighted

Command: "sct_propseg -i t1/t1.nii.gz -c t1 -init-centerline optic
Dataset: /Volumes/Public_JCA/sct_testing/large/
GLOBAL RESULTS:
Duration: 1483s
Passed: 75/116
Crashed: 0/116
Mean: {'dice_segmentation': 0.8661204544467307, 'duration [s]': 81.44691399048115}
STD: {'dice_segmentation': 0.18441609014819368, 'duration [s]': 30.866210507926827}

Command: "sct_propseg -i t1/t1.nii.gz -c t1
Dataset: /Volumes/Public_JCA/sct_testing/large/
GLOBAL RESULTS:
Duration: 1066s
Passed: 24/116
Crashed: 1/116
Mean: {'dice_segmentation': 0.6692521998875399, 'duration [s]': 52.99569157074238}
STD: {'dice_segmentation': 0.30516104566549374, 'duration [s]': 32.57508440274568}

results_t1

T2-weighted

Command: "sct_propseg -i t2/t2.nii.gz -c t2 -init-centerline optic
Dataset: /Volumes/Public_JCA/sct_testing/large/
GLOBAL RESULTS:
Duration: 1558s
Passed: 183/256
Crashed: 0/256
Mean: {'dice_segmentation': 0.8965265611318537, 'duration [s]': 41.221134138293564}
STD: {'dice_segmentation': 0.15291260300075263, 'duration [s]': 13.274626862061824}

Command: "sct_propseg -i t2/t2.nii.gz -c t2
Dataset: /Volumes/Public_JCA/sct_testing/large/
GLOBAL RESULTS:
Duration: 1549s
Passed: 118/256
Crashed: 36/256
Mean: {'dice_segmentation': 0.7161338428029882, 'duration [s]': 39.81973373796791}
STD: {'dice_segmentation': 0.3738910200186539, 'duration [s]': 18.235122280997768}

results_t2

T2*-weighted

Command: "sct_propseg -i t2s/t2s.nii.gz -c t2s -init-centerline optic
Dataset: /Volumes/Public_JCA/sct_testing/large/
GLOBAL RESULTS:
Duration: 1374s
Passed: 132/267
Crashed: 0/267
Mean: {'dice_segmentation': 0.8312970396151269, 'duration [s]': 32.0688976955771}
STD: {'dice_segmentation': 0.1911104445470129, 'duration [s]': 11.959219802345736}

Command: "sct_propseg -i t2s/t2s.nii.gz -c t2s
Dataset: /Volumes/Public_JCA/sct_testing/large/
GLOBAL RESULTS:
Duration: 11678s
Passed: 48/267
Crashed: 110/267
Mean: {'dice_segmentation': 0.5170396045760911, 'duration [s]': 241.19393977422394}
STD: {'dice_segmentation': 0.42351448517573337, 'duration [s]': 201.2540378294902}

results_t2s

I have enabled OptiC by default for PropSeg. To use old detection method, use option -init-centerline hough (should we hide it from the documentation or display it, knowing it is less robust?)

We should also replace the documentation concerning the contrast:

type of image contrast, t2: cord dark / CSF bright ; t1: cord bright / CSF dark

Proposition:

type of image contrast, if your contrast is not in the available options (t1, t2, t2s, dmri), use t1 (cord bright / CSF dark) or t2 (cord dark / CSF bright)

Je remplacerais dmri par dwi, car des gens pourraient penser qu'il sagit de la b=0 (qui est en fait T2w).

also, I would be allow more flexibility (e.g., if a contrast is not listed but ressembles more dwi, then they should use dwi, not t1):

~
type of image contrast. If your contrast is not in the available options, choose the one closest to your image. E.g.: for cord bright and CSF dark, choose "t1", or if cord is dark and CSF bright, choose "t2".
~

Bonne id茅e. Il faudrait changer le nom du mod猫le dans data/ aussi.

effectivement, je m'en occupe

Ca a l'air de crasher sur Travis, et je ne sais pas trop pourquoi:
https://travis-ci.org/neuropoly/spinalcordtoolbox/jobs/222376744#L514

Une id茅e?
sct_testing fonctionne bien chez moi.

les binaires linux ne sont pas encore sur osf ;-)

je fais ca asap

Cool. Par contre ca fait la m锚me erreur sur Travis/osx

ah mince... il faudrait faire un printout de l'erreur

@jcohenadad Oops (on Travis: https://travis-ci.org/neuropoly/spinalcordtoolbox/jobs/222478501#L655)

Checking test_sct_propseg...........................
OUTPUT:
--
sct_propseg  -v 1 -i /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/t2/t2.nii.gz -c t2 -r 1 -ofolder sct_propseg_sct_testing_data_170416025213_413774/
Running /home/travis/build/neuropoly/spinalcordtoolbox/scripts/sct_propseg.py -v 1 -i /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/t2/t2.nii.gz -c t2 -r 1 -ofolder sct_propseg_sct_testing_data_170416025213_413774/
Check folder existence...
Detecting the spinal cord using OptiC
/bin/sh: 1: isct_spine_detect: not found

But that's because Linux binaries are not available yet.

On OSX

OUTPUT:
--
sct_propseg  -v 1 -i /Users/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/t2/t2.nii.gz -c t2 -r 1 -ofolder sct_propseg_sct_testing_data_170416025239_384253/
Running /Users/travis/build/neuropoly/spinalcordtoolbox/scripts/sct_propseg.py -v 1 -i /Users/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/t2/t2.nii.gz -c t2 -r 1 -ofolder sct_propseg_sct_testing_data_170416025239_384253/
Check folder existence...
Detecting the spinal cord using OptiC
ERROR:: Environment variable FSLOUTPUTTYPE is not set!
Please make sure that the appropriate configuration file is sourced by your shell (e.g. by putting it in .profile).
e.g. bash or sh users add the line ". ${FSLDIR}/etc/fslconf/fsl.sh"
e.g. tcsh or csh users add the line "source ${FSLDIR}/etc/fslconf/fsl.csh"

Works on OSX now.

Works on linux (debian) as well.
I removed some todo:

  • add optic test --> already tested via propseg
  • add wrapper --> not urgent. Running propseg already output the centerline
Was this page helpful?
0 / 5 - 0 ratings

Related issues

saulo-p picture saulo-p  路  23Comments

Drulex picture Drulex  路  27Comments

PaulBautin picture PaulBautin  路  19Comments

jcohenadad picture jcohenadad  路  20Comments

jcohenadad picture jcohenadad  路  30Comments