sct_label_utils

U t i l i t y f u n c t i o n s f o r l a b e l i m a g e s . Utility functions for label images.

usage: sct_label_utils [-i <file>] [-o <file>] [-ilabel <file>]
                       (-add <int> | -create <list> | -create-add <list> | -create-seg <list> | -create-seg-mid <int> | -create-viewer <list> | -cubic-to-point | -project-centerline <file> | -display | -increment | -vert-body <list> | -vert-continuous | -MSE <file> | -remove-reference <file> | -remove-sym <file> | -remove <list> | -keep <list>)
                       [-msg <str>] [-qc <folder>] [-qc-dataset <str>]
                       [-qc-subject <str>] [-h] [-v <int>]

REQUIRED I/O

-i

I n p u t i m a g e ( R e q u i r e d ) E x a m p l e : ` t 2 _ l a b e l s . n i i . g z ` Input image (Required) Example: t2_labels.nii.gz

OPTIONAL I/O

-o

O u t p u t i m a g e . N o t e : O n l y s o m e l a b e l u t i l i t i e s c r e a t e a n o u t p u t i m a g e . Output image. Note: Only some label utilities create an output image.

D e f a u l t : ` ` ‘ l a b e l s . n i i . g z ‘ ` ` Default: 'labels.nii.gz'

-ilabel

F i l e t h a t c o n t a i n l a b e l s t h a t y o u w a n t t o c o r r e c t . I t i s p o s s i b l e t o a d d n e w p o i n t s w i t h t h i s o p t i o n . U s e w i t h ` - c r e a t e - v i e w e r ` . E x a m p l e : ` t 2 _ l a b e l s _ a u t o . n i i . g z ` File that contain labels that you want to correct. It is possible to add new points with this option. Use with -create-viewer. Example: t2_labels_auto.nii.gz

LABEL FUNCTIONS

-add

A d d v a l u e t o a l l l a b e l s . V a l u e c a n b e n e g a t i v e . Add value to all labels. Value can be negative.

-create

C r e a t e l a b e l s i n a n e w i m a g e . L i s t l a b e l s a s : x 1 , y 1 , z 1 , v a l u e 1 : x 2 , y 2 , z 2 , v a l u e 2 . E x a m p l e : 1 2 , 3 4 , 3 2 , 1 : 1 2 , 3 5 , 3 3 , 2 Create labels in a new image. List labels as: x1,y1,z1,value1:x2,y2,z2,value2. Example: 12,34,32,1:12,35,33,2

-create-add

S a m e a s ` - c r e a t e ` , b u t a d d l a b e l s t o t h e i n p u t i m a g e i n s t e a d o f c r e a t i n g a n e w i m a g e . E x a m p l e : 1 2 , 3 4 , 3 2 , 1 : 1 2 , 3 5 , 3 3 , 2 Same as -create, but add labels to the input image instead of creating a new image. Example: 12,34,32,1:12,35,33,2

-create-seg

C r e a t e l a b e l s o n a c o r d s e g m e n t a t i o n ( o r c e n t e r l i n e ) i m a g e d e f i n e d b y ` - i ` . E a c h l a b e l s h o u l d b e s p e c i f i e d u s i n g t h e f o r m ` v 1 , v 2 ` w h e r e ` v 1 ` i s v a l u e o f t h e s l i c e i n d e x a l o n g t h e i n f e r i o r - s u p e r i o r a x i s , a n d ` v 2 ` i s t h e v a l u e o f t h e l a b e l . S e p a r a t e e a c h l a b e l w i t h ` : ` . Create labels on a cord segmentation (or centerline) image defined by -i. Each label should be specified using the form v1,v2 where v1 is value of the slice index along the inferior-superior axis, and v2 is the value of the label. Separate each label with :.

E x a m p l e : ` - c r e a t e - s e g 5 , 1 : 1 4 , 2 : 2 3 , 3 ` a d d s t h r e e l a b e l s a t t h e a x i a l s l i c e s 5 , 1 4 , a n d 2 3 ( s t a r t i n g f r o m t h e m o s t i n f e r i o r s l i c e ) . Example: -create-seg 5,1:14,2:23,3 adds three labels at the axial slices 5, 14, and 23 (starting from the most inferior slice).

-create-seg-mid

S i m i l a r t o ` - c r e a t e - s e g ` . T h i s o p t i o n t a k e s a s i n g l e l a b e l v a l u e , a n d w i l l a u t o m a t i c a l l y s e l e c t t h e m i d - p o i n t s l i c e i n t h e i n f e r i o r - s u p e r i o r d i r e c t i o n ( s o t h e r e i s n o n e e d f o r a s l i c e i n d e x ) . Similar to -create-seg. This option takes a single label value, and will automatically select the mid-point slice in the inferior-superior direction (so there is no need for a slice index).

T h i s i s u s e f u l f o r w h e n y o u h a v e c e n t e r e d t h e f i e l d o f v i e w o f y o u r d a t a a t a s p e c i f i c l o c a t i o n . F o r e x a m p l e , i f y o u a l r e a d y k n o w t h a t t h e C 2 - C 3 d i s c i s c e n t e r e d i n t h e I - S d i r e c t i o n , t h e n y o u c a n e n t e r ` - c r e a t e - s e g - m i d 3 ` f o r t h a t l a b e l . T h i s s a v e s y o u t h e t r o u b l e o f h a v i n g t o m a n u a l l y s p e c i f y a s l i c e i n d e x u s i n g ` - c r e a t e - s e g ` . This is useful for when you have centered the field of view of your data at a specific location. For example, if you already know that the C2-C3 disc is centered in the I-S direction, then you can enter -create-seg-mid 3 for that label. This saves you the trouble of having to manually specify a slice index using -create-seg.

-create-viewer

M a n u a l l y l a b e l f r o m a G U I a l i s t o f l a b e l s I D s . P r o v i d e a c o m m a - s e p a r a t e d l i s t c o n t a i n i n g i n d i v i d u a l v a l u e s a n d / o r i n t e r v a l s . E x a m p l e : ` - c r e a t e - v i e w e r 1 : 4 , 6 , 8 ` w i l l a l l o w y o u t o a d d l a b e l s [ 1 , 2 , 3 , 4 , 6 , 8 ] u s i n g t h e G U I . Manually label from a GUI a list of labels IDs. Provide a comma-separated list containing individual values and/or intervals. Example: -create-viewer 1:4,6,8 will allow you to add labels [1,2,3,4,6,8] using the GUI.

-cubic-to-point

C o m p u t e t h e c e n t e r - o f - m a s s f o r e a c h l a b e l v a l u e . Compute the center-of-mass for each label value.

D e f a u l t : ` ` F a l s e ` ` Default: False

-project-centerline

P r o j e c t l a b e l s ( e . g . d i s c l a b e l s ) o n t o a s p i n a l c o r d s e g m e n t a t i o n o r c e n t e r l i n e . E x a m p l e : s c t _ l a b e l _ u t i l s - i s p i n a l c o r d . n i i . g z - p r o j e c t - c e n t e r l i n e l a b e l s . n i i . g z Project labels (e.g. disc labels) onto a spinal cord segmentation or centerline. Example: sct_label_utils -i spinalcord.nii.gz -project-centerline labels.nii.gz

-display

D i s p l a y a l l l a b e l s ( i . e . n o n - z e r o v a l u e s ) . Display all labels (i.e. non-zero values).

D e f a u l t : ` ` F a l s e ` ` Default: False

-increment

T a k e s a l l n o n - z e r o v a l u e s , s o r t t h e m a l o n g t h e i n v e r s e z d i r e c t i o n , a n d a t t r i b u t e s t h e v a l u e s 1 , 2 , 3 , e t c . Takes all non-zero values, sort them along the inverse z direction, and attributes the values 1, 2, 3, etc.

D e f a u l t : ` ` F a l s e ` ` Default: False

-vert-body

F r o m v e r t e b r a l l a b e l i n g , c r e a t e p o i n t s t h a t a r e c e n t e r e d a t t h e m i d - v e r t e b r a l l e v e l s . S e p a r a t e d e s i r e d l e v e l s w i t h ` , ` . E x a m p l e : ` 3 , 8 ` From vertebral labeling, create points that are centered at the mid-vertebral levels. Separate desired levels with ,. Example: 3,8

T o g e t a l l l e v e l s , e n t e r 0 . To get all levels, enter 0.

-vert-continuous

C o n v e r t d i s c r e t e v e r t e b r a l l a b e l i n g t o c o n t i n u o u s v e r t e b r a l l a b e l i n g . Convert discrete vertebral labeling to continuous vertebral labeling.

D e f a u l t : ` ` F a l s e ` ` Default: False

-MSE

C o m p u t e M e a n S q u a r e E r r o r b e t w e e n l a b e l s f r o m i n p u t a n d r e f e r e n c e i m a g e . S p e c i f y r e f e r e n c e i m a g e h e r e . Compute Mean Square Error between labels from input and reference image. Specify reference image here.

-remove-reference

R e m o v e l a b e l s f r o m i n p u t i m a g e ( ` - i ` ) t h a t a r e n o t i n r e f e r e n c e i m a g e ( s p e c i f i e d h e r e ) . Remove labels from input image (-i) that are not in reference image (specified here).

-remove-sym

R e m o v e l a b e l s f r o m i n p u t i m a g e ( ` - i ` ) a n d r e f e r e n c e i m a g e ( s p e c i f i e d h e r e ) t h a t d o n ‘ t m a t c h . Y o u m u s t p r o v i d e t w o o u t p u t n a m e s s e p a r a t e d b y ` , ` . Remove labels from input image (-i) and reference image (specified here) that don’t match. You must provide two output names separated by ,.

-remove

R e m o v e l a b e l s o f s p e c i f i c v a l u e ( s p e c i f i e d h e r e ) f r o m r e f e r e n c e i m a g e . Remove labels of specific value (specified here) from reference image.

-keep

K e e p l a b e l s o f s p e c i f i c v a l u e ( s p e c i f i e d h e r e ) f r o m r e f e r e n c e i m a g e . Keep labels of specific value (specified here) from reference image.

OPTIONAL ARGUMENTS

-msg

D i s p l a y a m e s s a g e t o e x p l a i n t h e l a b e l i n g t a s k . U s e w i t h - c r e a t e - v i e w e r Display a message to explain the labeling task. Use with -create-viewer

-qc

T h e p a t h w h e r e t h e q u a l i t y c o n t r o l g e n e r a t e d c o n t e n t w i l l b e s a v e d . The path where the quality control generated content will be saved.

-qc-dataset

I f p r o v i d e d , t h i s s t r i n g w i l l b e m e n t i o n e d i n t h e Q C r e p o r t a s t h e d a t a s e t t h e p r o c e s s w a s r u n o n . If provided, this string will be mentioned in the QC report as the dataset the process was run on.

-qc-subject

I f p r o v i d e d , t h i s s t r i n g w i l l b e m e n t i o n e d i n t h e Q C r e p o r t a s t h e s u b j e c t t h e p r o c e s s w a s r u n o n . If provided, this string will be mentioned in the QC report as the subject the process was run on.

MISC ARGUMENTS

-v

P o s s i b l e c h o i c e s : 0 , 1 , 2 Possible choices: 0, 1, 2

V e r b o s i t y . 0 : D i s p l a y o n l y e r r o r s / w a r n i n g s , 1 : E r r o r s / w a r n i n g s + i n f o m e s s a g e s , 2 : D e b u g m o d e . Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode.

D e f a u l t : ` ` 1 ` ` Default: 1