help > ROI file from SPM created outside of CONN
Showing 1-5 of 5 posts
Display:
Results per page:
Jan 4, 2017  03:01 PM | Scott Burwell - Minnesota Center for Twin and Family Research - University of Minnesota
ROI file from SPM created outside of CONN
Greetings, 

I am hoping that someone can point me to a function (MATLAB or not) that will take a *.nii file generated outside of CONN, conduct thresholding (and binary transform), and produce an ROI file much like like that which is produced by "Export mask" in the seed-to-voxel results window. I know that FSL has commands that can threshold and binarize an image file, but the output only generates 1 "ROI," such that any values above threshold would be considered within the same ROI. My dilemma is this: I have two regions of interest that exceed threshold (in the right and left hemispheres) and I want to interrogate them as ROIs separately. Again, if the SPMs were generated in CONN as second-level results, this would be easy (via "Export mask"), but they were generated outside of CONN and I am yet to find a program that does this.

Thank you in advance!

Scott
Jan 4, 2017  04:01 PM | Pravesh Parekh - National Institute of Mental Health and Neurosciences
RE: ROI file from SPM created outside of CONN
Hi Scott,

I recommend using the imcalc utility of SPM to do this. If you want the left and right sides to be separate mask, prior to the thresholding and binarizing in imcalc, you could multiply the image with a binary mask of left and right. You can create left and right binary mask as follows:

1) Load a whole brain mask (such as one shipped with Conn)
2) read in the xyz coordinates (see spm_read_vols function)
3) find all entries with x <= 0 and set them to 1 [this become the left brain mask]
4) write the file
5) similarly find all entries with x > 0 and set them to 1 [this becomes the right brain mask]
6) write this out (see spm_write_vol function to write these files)
 
Once you have these masks, you can simply multiply your .nii file with the left mask, threshold, and binarize (this is your left ROI) and repeat with right mask for right ROI. You can do the thresholding and binarizing using imcalc or manually. 

The process of making a left/right whole brain mask sounds slightly cumbersome but is quite doable (perhaps someone has a better trick to do it?). Let me know if you would like me to elaborate any of the steps...


Best
Pravesh

P.S: You don't actually need to write the L/R mask files separately (though writing them down would help if you want to re-use them at some point of time). All the steps can be written up into a  tiny script and reused... 

Originally posted by Scott Burwell:
Greetings, 

I am hoping that someone can point me to a function (MATLAB or not) that will take a *.nii file generated outside of CONN, conduct thresholding (and binary transform), and produce an ROI file much like like that which is produced by "Export mask" in the seed-to-voxel results window. I know that FSL has commands that can threshold and binarize an image file, but the output only generates 1 "ROI," such that any values above threshold would be considered within the same ROI. My dilemma is this: I have two regions of interest that exceed threshold (in the right and left hemispheres) and I want to interrogate them as ROIs separately. Again, if the SPMs were generated in CONN as second-level results, this would be easy (via "Export mask"), but they were generated outside of CONN and I am yet to find a program that does this.

Thank you in advance!

Scott
Jan 4, 2017  04:01 PM | Scott Burwell - Minnesota Center for Twin and Family Research - University of Minnesota
RE: ROI file from SPM created outside of CONN
Thank you so much for your quick reply, Pravesh.

My apologies that I failed to mention that the ROI file I am trying to make has more than just bilateral sources, but also some that "straddle" the midline (critical information I oversimplified). Specifically, I have derived an "anterior salience network" from my data using Infomax ICA from the GIFT toolbox (please see attached image). [I know that ICA is implemented in CONN but there is less freedom over choice of parameters in CONN, so I would like to do the ICA in GIFT]. The suggestion you have would definitely work if my only ROIs were bilateral, though, so thank you for that and I will keep it in mind.

Would anyone happen to know of a trick or tool that does not require creating a priori masks to isolate regions of the SPM? I would ultimately like to have 5 ROIs (again, please see attached figure) that are specific to the ICA conducted on my data.

Again, thank you in advance!
Scott
Attachment: aSN_SPMthr.PNG
Jan 4, 2017  05:01 PM | Pravesh Parekh - National Institute of Mental Health and Neurosciences
RE: ROI file from SPM created outside of CONN
Hi Scott,

I have a slightly round-about suggestion on how to deal with the situation (I don't know if there is a better solution available). The attachment helped. The following assumes that your data is normalized (in MNI space):

1. Read a brain atlas that has labels for your regions of interest into MATLAB (spm_read_vols)
2. Read your .nii file into MATLAB as well
3. For all voxels above threshold (in your .nii file), find the corresponding entry in the brain atlas (because they are in the same space, you are simply "labeling" your voxels)
4. Now each of your ROIs would have different intensity values...you can simply write these off as individual files

The caveat in this method would be if one ROI has multiple labels...in which case you would have to do a bit of manual manipulation.

Do let me know if you would want me to go into details for the above steps...

Best
Pravesh
 
Originally posted by Scott Burwell:
Thank you so much for your quick reply, Pravesh.

My apologies that I failed to mention that the ROI file I am trying to make has more than just bilateral sources, but also some that "straddle" the midline (critical information I oversimplified). Specifically, I have derived an "anterior salience network" from my data using Infomax ICA from the GIFT toolbox (please see attached image). [I know that ICA is implemented in CONN but there is less freedom over choice of parameters in CONN, so I would like to do the ICA in GIFT]. The suggestion you have would definitely work if my only ROIs were bilateral, though, so thank you for that and I will keep it in mind.

Would anyone happen to know of a trick or tool that does not require creating a priori masks to isolate regions of the SPM? I would ultimately like to have 5 ROIs (again, please see attached figure) that are specific to the ICA conducted on my data.

Again, thank you in advance!
Scott
Jan 4, 2017  06:01 PM | Scott Burwell - Minnesota Center for Twin and Family Research - University of Minnesota
RE: ROI file from SPM created outside of CONN
Thank you again Pravesh, I will look into this and give it a shot.

Best,
Scott