Loosing 4th dimension after segmentation

Hi,

My original nifti file is having 4dimensions , i.e., ( 196, 240, 100, 1). I have done segmentation in 3d slicer using 2 labels, and after saving the segmented file, it is giving me output as 3d. My new dimensions are (196, 240, 100) but my time dimension has vanished. I have used reference volume option as while before exporting but it didnt give me my output. I would request you to help.

Thanks in advance.

NIFTI file format is causing lot of trouble, as its specification contains lots of unnecesary complexity (redundancies and ambiguities). Therefore we are not keen on spending time with it, which means nobody ventured to implement support for 4D NIFTI files (except for displacement fields). Therefore, if you export a segmentation into NIFTI format from Slicer, the output will always be a 3D file.

One possible solution is to write the segmentation to NRRD file format and then read it and then write in NIFTI format. You can implement this in a few lines in Python using pynrrd and nibabel packages.

If your input NIFTI file has size of (196, 240, 100, 1) then it means that it is actually a 3D image. Why is it important to save as a 4D image if the 4th dimension is singular?

Thank you for your reply. I have converted my dicom images initially to nifti using dcm2niix. Later, I am doing segmentation and doing it manually using 3d slicer. I need time information because I am using a python code which checks the quality of Nifti files with respect to time and, later, calculates the area. Either i am not doing segmentation properly or I need to follow some other approach to convert 1. dicom to nifti and, later, 2. nifti to segmented nifti.

For now, i will convert my dicom to nrrd file (as you suggested) and later, will convert it to nifti and try it in different cases. I will check if it gives me time information as well. (My dicom images does have time information)

my converted 100 dicom images to nifti has header -

sizeof_hdr : 348
data_type : b’’
db_name : b’’
extents : 0
session_error : 0
regular : b’r’
dim_info : 57
dim : [ 4 240 196 1 100 1 1 1]
intent_p1 : 0.0
intent_p2 : 0.0
intent_p3 : 0.0
intent_code : none
datatype : int16
bitpix : 16
slice_start : 0
pixdim : [-1. 1.5833334 1.5833334 6. 0.028 0.
0. 0. ]
vox_offset : 0.0
scl_slope : nan
scl_inter : nan
slice_end : 0
slice_code : unknown
xyzt_units : 10
cal_max : 0.0
cal_min : 0.0
slice_duration : 0.0
toffset : 0.0
glmax : 0
glmin : 0
descrip : b’TE=1.2;Time=103829.298;phase=1’
aux_file : b’RR 872 +/- 61; 9 heartb’
qform_code : scanner
sform_code : scanner
quatern_b : 0.0
quatern_c : 1.0
quatern_d : 0.0
qoffset_x : 191.80186
qoffset_y : -134.34802
qoffset_z : 43.5763
srow_x : [ -1.5833334 0. -0. 191.80186 ]
srow_y : [ -0. 1.5833334 -0. -134.34802 ]
srow_z : [ 0. 0. 6. 43.5763]
intent_name : b’’
magic : b’n+1’

whereas my segmentation file doesn’t have time stamp
sizeof_hdr : 348
data_type : b’’
db_name : b’’
extents : 0
session_error : 0
regular : b’r’
dim_info : 0
dim : [ 4 240 196 1 100 1 1 1]
intent_p1 : 0.0
intent_p2 : 0.0
intent_p3 : 0.0
intent_code : none
datatype : uint16
bitpix : 16
slice_start : 0
pixdim : [-1. 1.5833334 1.5833334 6. 0.028 0.
0. 0. ]
vox_offset : 0.0
scl_slope : nan
scl_inter : nan
slice_end : 0
slice_code : unknown
xyzt_units : 2
cal_max : 0.0
cal_min : 0.0
slice_duration : 0.0
toffset : 0.0
glmax : 0
glmin : 0
descrip : b’’
aux_file : b’’
qform_code : scanner
sform_code : scanner
quatern_b : -0.0
quatern_c : 1.0
quatern_d : 0.0
qoffset_x : 191.80186
qoffset_y : -134.34802
qoffset_z : 43.5763
srow_x : [ -1.5833334 -0. 0. 191.80186 ]
srow_y : [ -0. 1.5833334 -0. -134.34802 ]
srow_z : [ 0. 0. 6. 43.5763]
intent_name : b’’
magic : b’n+1’

Could you please suggest me how can i get the time stamp and i believe i am loosing some other informattion here as well…

and by converting dicom to nrrd :

OrderedDict([(‘type’, ‘unsigned short’), (‘dimension’, 3), (‘space’, ‘left-posterior-superior’), (‘sizes’, array([240, 196, 100])), (‘space directions’, array([[1.58333337, 0. , 0. ],
[0. , 1.58333337, 0. ],
[0. , 0. , 1. ]])), (‘kinds’, [‘domain’, ‘domain’, ‘domain’]), (‘endian’, ‘little’), (‘encoding’, ‘gzip’), (‘space origin’, array([-191.80186367, -174.40197062, 43.57630157]))])

i am not getting the required information.