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

Demo does not support this data type (solution: use niimath) #3

Closed
Thinking-leaf opened this issue May 8, 2022 · 6 comments
Closed

Comments

@Thinking-leaf
Copy link

Hello, I met a problem when using nii2mesh.
./nii2mesh $SUBJECTS_DIR/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz -p 1 -l 0 -s 100 $SUBJECTS_DIR/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala.p1l0s100.stl
Demo does not support this data type (solution: use niimath)

I don't know why this error rises even when the input format is NIFTI. And after this, I tried to solve this by installing niimath but nothing changed.
So what's wrong?

@neurolabusc
Copy link
Owner

What datatype is your image? You use niimath to detect the data type:

$ niimath $SUBJECTS_DIR/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz
<nifti_image
  nifti_type = 'NIFTI-1+'
  header_filename = 'sag_int_36sl_21.nii'
  image_filename = 'sag_int_36sl_21.nii'
  image_offset = '352'
  ndim = '4'
  nx = '64'
  ny = '64'
  nz = '36'
  nt = '2'
  dx = '3.25'
  dy = '3.25'
  dz = '3.6'
  dt = '3'
  datatype = '4'
  datatype_name = 'INT16'

nii2mesh only supports the most popular data types (DT_UINT8 DT_UINT16 DT_INT16 DT_FLOAT32). Since niimath exports to float32 by default, you could try:

niimath $SUBJECTS_DIR/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz -add 0 flt32

@Thinking-leaf
Copy link
Author

Thanks for your comment. As you can see below, the datatype of this nifti file is 'INT32'
$ niimath $SUBJECTS_DIR/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz
<nifti_image
nifti_type = 'NIFTI-1+'
header_filename = '/Applications/freesurfer/7.2.0/trial2/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz'
image_filename = '/Applications/freesurfer/7.2.0/trial2/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz'
image_offset = '352'
ndim = '3'
nx = '176'
ny = '256'
nz = '256'
dx = '0.999998'
dy = '1'
dz = '1'
datatype = '8'
datatype_name = 'INT32'
nvox = '11534336'
nbyper = '4'
byteorder = 'LSB_FIRST'
xyz_units = '2'
xyz_units_name = 'mm'
time_units = '8'
time_units_name = 's'
descrip = 'FreeSurfer Jul 13 2021'
qform_code = '1'
qform_code_name = 'Scanner Anat'
qto_xyz_matrix = '0.996803 -0.013412 0.0787298 -89.019 0.00732101 0.996993 0.0771508 -108.054 -0.0795276 -0.076328 0.993906 -146.884 0 0 0 1'
qto_ijk_matrix = '0.996808 0.00732104 -0.0795279 77.8446 -0.013412 0.996993 -0.076328 95.3233 0.0787298 0.0771508 0.993906 161.334 0 0 0 1'
quatern_b = '-0.0384288'
quatern_c = '0.0396253'
quatern_d = '0.00519125'
qoffset_x = '-89.019'
qoffset_y = '-108.054'
qoffset_z = '-146.884'
qfac = '1'
qform_i_orientation = 'Left-to-Right'
qform_j_orientation = 'Posterior-to-Anterior'
qform_k_orientation = 'Inferior-to-Superior'
sform_code = '1'
sform_code_name = 'Scanner Anat'
sto_xyz_matrix = '0.996803 -0.013412 0.0787298 -89.019 0.00732101 0.996993 0.0771508 -108.054 -0.0795276 -0.076328 0.993906 -146.884 0 0 0 1'
sto_ijk matrix = '0.996808 0.00732104 -0.0795279 77.8446 -0.013412 0.996993 -0.076328 95.3233 0.0787298 0.0771508 0.993906 161.334 0 0 0 1'
sform_i_orientation = 'Left-to-Right'
sform_j_orientation = 'Posterior-to-Anterior'
sform_k_orientation = 'Inferior-to-Superior'
num_ext = '0'
/>
However, after running the code
niimath $SUBJECTS_DIR/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz -add 0 flt32
I recheck its datatype, nothing changed.
<nifti_image
nifti_type = 'NIFTI-1+'
header_filename = '/Applications/freesurfer/7.2.0/trial2/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz'
image_filename = '/Applications/freesurfer/7.2.0/trial2/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz'
image_offset = '352'
ndim = '3'
nx = '176'
ny = '256'
nz = '256'
dx = '0.999998'
dy = '1'
dz = '1'
datatype = '8'
datatype_name = 'INT32'
nvox = '11534336'
nbyper = '4'
byteorder = 'LSB_FIRST'
xyz_units = '2'
xyz_units_name = 'mm'
time_units = '8'
time_units_name = 's'
descrip = 'FreeSurfer Jul 13 2021'
qform_code = '1'
qform_code_name = 'Scanner Anat'
qto_xyz_matrix = '0.996803 -0.013412 0.0787298 -89.019 0.00732101 0.996993 0.0771508 -108.054 -0.0795276 -0.076328 0.993906 -146.884 0 0 0 1'
qto_ijk_matrix = '0.996808 0.00732104 -0.0795279 77.8446 -0.013412 0.996993 -0.076328 95.3233 0.0787298 0.0771508 0.993906 161.334 0 0 0 1'
quatern_b = '-0.0384288'
quatern_c = '0.0396253'
quatern_d = '0.00519125'
qoffset_x = '-89.019'
qoffset_y = '-108.054'
qoffset_z = '-146.884'
qfac = '1'
qform_i_orientation = 'Left-to-Right'
qform_j_orientation = 'Posterior-to-Anterior'
qform_k_orientation = 'Inferior-to-Superior'
sform_code = '1'
sform_code_name = 'Scanner Anat'
sto_xyz_matrix = '0.996803 -0.013412 0.0787298 -89.019 0.00732101 0.996993 0.0771508 -108.054 -0.0795276 -0.076328 0.993906 -146.884 0 0 0 1'
sto_ijk matrix = '0.996808 0.00732104 -0.0795279 77.8446 -0.013412 0.996993 -0.076328 95.3233 0.0787298 0.0771508 0.993906 161.334 0 0 0 1'
sform_i_orientation = 'Left-to-Right'
sform_j_orientation = 'Posterior-to-Anterior'
sform_k_orientation = 'Inferior-to-Superior'
num_ext = '0'
/>
lh.amygdala_mask-in-rawavg.nii.gz

So demo still doesn't support the data type (solution:use niimath)
how to use niimath to solve this problem? I attached the sample nifti file here so that you can have a try on it. Thanks for your help!

@neurolabusc
Copy link
Owner

Your call to niimath created a new image named flt32.nii.gz that will be in float 32 format. The idea was to create a copy of your input image.

@Thinking-leaf
Copy link
Author

Oh, sorry for my being unfamiliar with this toolbox. Brilliant idea! It saves my work!
But I have multiple works and how can I define the name and path of the output images?

@neurolabusc
Copy link
Owner

You can use Python, Matlab or bash scripts to automate this. FSL has a lot of helper bash functions to automate tasks. The inner loopo of your bash script would look like:

niimath ${inname} -dehaze 5 temp
nii2mesh temp -dehaze 5 ${inname}

@Thinking-leaf
Copy link
Author

Thanks again! Here is my final code
#!/bin/tcsh
foreach subject (sub*)
niimath $SUBJECTS_DIR/{$subject}/mri/rh.amygdala_mask-in-rawavg.nii.gz -add 0 $SUBJECTS_DIR/{$subject}/mri/rh.amygdala_mask-in-rawavg.(flt32).nii.gz
./nii2mesh $SUBJECTS_DIR/{$subject}/mri/rh.amygdala_mask-in-rawavg.(flt32).nii.gz -q 2 -p 1 -l 0 $SUBJECTS_DIR/{$subject}/mri/lh.amygdala_q2p1l0.gz
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants