help
help > RE: Lesion Masks
Mar 15, 2021 01:03 PM | Alana Batista
RE: Lesion Masks
Hi Afonso,
I also work with Stroke patients and I m trying to use CONN. I read your suggestions and I tried to modify the TPM.mat using the script you suggested. I used a lesion mask drawer on subject native space with values of 1 in the lesion and 0 elsewere. Also tried to use an inverted lesion mask where the values inside the lesions were zero. But I faced the same error message and I don't know what to do because I'm doing this for the fist time.
Can you kindly help with that?
Thank you!
Alana Batista
The code and the error message is displayed below
spm_imcalc({'/Users/alanabatista/Documents/MATLAB/spm12/tpm/TPM.nii,1','/Users/alanabatista/Desktop/Teste/TPM/C001413/C001433LesionMaskbin.nii'},'/Users/alanabatista/Desktop/Teste/TPM/C001433/MyResampledLesionMask.nii','i2');
spm_file_merge({'/Users/alanabatista/Documents/MATLAB/spm12/tpm/TPM.nii','/Users/alanabatista/Desktop/Teste/TPM/C001413/MyResampledLesionMask.nii'},'/Users/alanabatista/Desktop/Teste/TPM/C001433/C001433TPM.nii');
SPM12: spm_imcalc (v6961) 10:51:01 - 15/03/2021
========================================================================
Warning: The images do not all have the same dimensions. - using 1st image.
Warning: The images do not all have same orientation and/or voxel sizes. - using 1st image.
Error: No such file or directory
There was a problem writing to the header of
"/Users/alanabatista/Desktop/Teste/TPM/C001433/MyResampledLesionMask.nii"
Error using nifti/create (line 26)
Unable to write header for "/Users/alanabatista/Desktop/Teste/TPM/C001433/MyResampledLesionMask.nii".
Error in spm_create_vol>create_vol (line 210)
create(N);
Error in spm_create_vol (line 17)
v = create_vol(V(i));
Error in spm_write_vol (line 83)
V = spm_create_vol(V);
Error in spm_imcalc (line 220)
Vo = spm_write_vol(Vo,Y);
Error in TPMLesion (line 1)
spm_imcalc({'/Users/alanabatista/Documents/MATLAB/spm12/tpm/TPM.nii,1','/Users/alanabatista/Desktop/Teste/TPM/C001413/C001433LesionMaskbin.nii'},'/Users/alanabatista/Desktop/Teste/TPM/C001433/MyResampledLesionMask.nii','i2');
Originally posted by Alfonso Nieto-Castanon:
I also work with Stroke patients and I m trying to use CONN. I read your suggestions and I tried to modify the TPM.mat using the script you suggested. I used a lesion mask drawer on subject native space with values of 1 in the lesion and 0 elsewere. Also tried to use an inverted lesion mask where the values inside the lesions were zero. But I faced the same error message and I don't know what to do because I'm doing this for the fist time.
Can you kindly help with that?
Thank you!
Alana Batista
The code and the error message is displayed below
spm_imcalc({'/Users/alanabatista/Documents/MATLAB/spm12/tpm/TPM.nii,1','/Users/alanabatista/Desktop/Teste/TPM/C001413/C001433LesionMaskbin.nii'},'/Users/alanabatista/Desktop/Teste/TPM/C001433/MyResampledLesionMask.nii','i2');
spm_file_merge({'/Users/alanabatista/Documents/MATLAB/spm12/tpm/TPM.nii','/Users/alanabatista/Desktop/Teste/TPM/C001413/MyResampledLesionMask.nii'},'/Users/alanabatista/Desktop/Teste/TPM/C001433/C001433TPM.nii');
SPM12: spm_imcalc (v6961) 10:51:01 - 15/03/2021
========================================================================
Warning: The images do not all have the same dimensions. - using 1st image.
Warning: The images do not all have same orientation and/or voxel sizes. - using 1st image.
Error: No such file or directory
There was a problem writing to the header of
"/Users/alanabatista/Desktop/Teste/TPM/C001433/MyResampledLesionMask.nii"
Error using nifti/create (line 26)
Unable to write header for "/Users/alanabatista/Desktop/Teste/TPM/C001433/MyResampledLesionMask.nii".
Error in spm_create_vol>create_vol (line 210)
create(N);
Error in spm_create_vol (line 17)
v = create_vol(V(i));
Error in spm_write_vol (line 83)
V = spm_create_vol(V);
Error in spm_imcalc (line 220)
Vo = spm_write_vol(Vo,Y);
Error in TPMLesion (line 1)
spm_imcalc({'/Users/alanabatista/Documents/MATLAB/spm12/tpm/TPM.nii,1','/Users/alanabatista/Desktop/Teste/TPM/C001413/C001433LesionMaskbin.nii'},'/Users/alanabatista/Desktop/Teste/TPM/C001433/MyResampledLesionMask.nii','i2');
Originally posted by Alfonso Nieto-Castanon:
Hi Hanna
Sorry there is no yet streamlined procedure to do this. I would recommend creating a modified TPM.mat file by adding you lesion mask as an additional tissue class. You can do that, for example, using something like the following (change the folder and file names accordingly):
The first line resamples your original lesion mask to the same size & orientation as SPM's default TPM file, and the second line creates a new TPM file by concatenating the SPM's default TPM file with your new (resampled) lesion file.
Last, when you run functional or structural normalization in CONN you may simply use your modified newTPM.nii file by either: a) (in the GUI) when prompted uncheck the option labeled 'use default Tissue Probability Map' and select the new file there; or b) (using batch) enter the new TPM file in the field "batch.Setup.preprocessing.tpm_template". By default CONN will use a mixture of 4 gaussians to fit the intensity distribution within any newly defined tissue classes, if you prefer to change that behavior you may do that using the batch field "batch.Setup.preprocessing.tpm_ngaus"
Hope this helps
Alfonso
Originally posted by hannasofia:
Sorry there is no yet streamlined procedure to do this. I would recommend creating a modified TPM.mat file by adding you lesion mask as an additional tissue class. You can do that, for example, using something like the following (change the folder and file names accordingly):
spm_imcalc({'/software/spm12/tpm/TPM.nii,1','/data/MyOriginalLesionMask.nii'},'/data/MyResampledLesionMask.nii','i2');
spm_file_merge({'/software/spm12/tpm/TPM.nii',
'/data/MyResampledLesionMask.nii'}, '/data/MyNewTPM.nii');
The first line resamples your original lesion mask to the same size & orientation as SPM's default TPM file, and the second line creates a new TPM file by concatenating the SPM's default TPM file with your new (resampled) lesion file.
Last, when you run functional or structural normalization in CONN you may simply use your modified newTPM.nii file by either: a) (in the GUI) when prompted uncheck the option labeled 'use default Tissue Probability Map' and select the new file there; or b) (using batch) enter the new TPM file in the field "batch.Setup.preprocessing.tpm_template". By default CONN will use a mixture of 4 gaussians to fit the intensity distribution within any newly defined tissue classes, if you prefer to change that behavior you may do that using the batch field "batch.Setup.preprocessing.tpm_ngaus"
Hope this helps
Alfonso
Originally posted by hannasofia:
Hi,
I would like to mask out stroke lesions but cannot find a way to do so. Conn is a very good program and it would be great if this could be done in the preporocessing in Conn.
I found the following thread (see below) but do not know how to actually do it. Can I enter a seventh tissue class in one of the preprocessing steps in conn? Do I have to import a mask of the lesion? If so, can it be from ITK snap saved as a nifti file? Or can I draw the lesion in Conn? If this is not possible, should a TPM file be created and where is that done and where do I import it into conn?
Any help would be highly appreciated.
Best Regards,
Hanna
Originally posted by Giuliana Giorjiani:
I would like to mask out stroke lesions but cannot find a way to do so. Conn is a very good program and it would be great if this could be done in the preporocessing in Conn.
I found the following thread (see below) but do not know how to actually do it. Can I enter a seventh tissue class in one of the preprocessing steps in conn? Do I have to import a mask of the lesion? If so, can it be from ITK snap saved as a nifti file? Or can I draw the lesion in Conn? If this is not possible, should a TPM file be created and where is that done and where do I import it into conn?
Any help would be highly appreciated.
Best Regards,
Hanna
Originally posted by Giuliana Giorjiani:
Dear
all,
How could I modify the TPM.nii file? Should I add a new 3D image to the TPM.nii file with the lesion masks of all my subjects?
Thanks!
Giuliana
Originally posted by Alfonso Nieto-Castanon:
How could I modify the TPM.nii file? Should I add a new 3D image to the TPM.nii file with the lesion masks of all my subjects?
Thanks!
Giuliana
Originally posted by Alfonso Nieto-Castanon:
Hi Cole,
The procedure in SPM12 to include lesion masks is to modify the file TPM.nii (tissue probability maps) by adding a new tissue class indicating the spatial distribution of the lesions. You may either modify SPM's TPM.nii file directly (located in spm12/tpm/TPM.nii), or define your own TPM.nii file and let CONN know that you would like to use that alternative tpm file instead (e.g. if using batch scripts in CONN you would do this using the fields batch.Setup.preprocessing.tpm_template and batch.Setup.preprocessing.tpm_ngauss)
Hope this helps
Alfonso
Originally posted by Cole Sugden:
The procedure in SPM12 to include lesion masks is to modify the file TPM.nii (tissue probability maps) by adding a new tissue class indicating the spatial distribution of the lesions. You may either modify SPM's TPM.nii file directly (located in spm12/tpm/TPM.nii), or define your own TPM.nii file and let CONN know that you would like to use that alternative tpm file instead (e.g. if using batch scripts in CONN you would do this using the fields batch.Setup.preprocessing.tpm_template and batch.Setup.preprocessing.tpm_ngauss)
Hope this helps
Alfonso
Originally posted by Cole Sugden:
Hello!
Some of my participants have very large lesions due to arterial stroke and the segmentation process has incorrectly classified the lesion as grey and white matter rather than CSF. To try to adjust for this and to help with normalisation, I would like to use Cost Function masking to individually fix the issue.
My question is, at which point in preprocessing can I enter the lesion mask image? It does not seem to be an option in SPM12 and I prefer to use CONN. Is there a way I would be able to manually enter them somewhere?
Thanks!
Cole
Some of my participants have very large lesions due to arterial stroke and the segmentation process has incorrectly classified the lesion as grey and white matter rather than CSF. To try to adjust for this and to help with normalisation, I would like to use Cost Function masking to individually fix the issue.
My question is, at which point in preprocessing can I enter the lesion mask image? It does not seem to be an option in SPM12 and I prefer to use CONN. Is there a way I would be able to manually enter them somewhere?
Thanks!
Cole
Threaded View
Title | Author | Date |
---|---|---|
Cole Sugden | May 26, 2016 | |
Marcela Takahashi | Mar 21, 2019 | |
Alfonso Nieto-Castanon | May 28, 2016 | |
Giuliana Giorjiani | Dec 6, 2018 | |
hannasofia | Dec 4, 2019 | |
Alfonso Nieto-Castanon | Dec 6, 2019 | |
Alana Batista | Mar 15, 2021 | |
Fabian Messmer | May 14, 2021 | |
Marianna La Rocca | Apr 6, 2020 | |
Matthew Heard | Jan 21, 2019 | |
Wouter De Baene | Apr 25, 2019 | |
Gianluca Saetta | Feb 17, 2019 | |