Back to PLS Help

Functional brain coverage
vmclelland
Posted on 11/19/13 20:02:12
Number of posts: 11
vmclelland posts:

Is there a way to acquire an image depicting all of the voxels that are treated as 'brain' across subjects in PLS, similar to a group mask in SPM?

Replies:

Untitled Post

I'm Online
jshen
Posted on 11/19/13 20:32:58
Number of posts: 291
jshen replies:

For PET, E.R.fMRI and Blocked fMRI module, there is a check box called "Consider all voxels as brain" in "Create Datamat" window. If you select check for this check box, all of the voxels will be treated as "Brain Region".

 



Untitled Post
vmclelland
Posted on 11/19/13 21:16:01
Number of posts: 11
vmclelland replies:

Hi Jimmy - thanks for your reply. If I haven't checked that box, and instead chose to define the brain region automatically using the default, is there a way to visualize the included voxels across participants?



Untitled Post

I'm Online
jshen
Posted on 11/19/13 21:49:35
Number of posts: 291
jshen replies:

Answers:

  1. If you chose the default "Define brain region automatically", you did not treat all of the voxels as "Brain Region".
  2. If you want to visualize the included voxels for a particular subject, you can click "Check image orientation" button in "Create Datamat" window.
  3. There is no way to visualize them across participants, since we intersect the "Brain Region" on fly. However, I can provide you with a workaround below.

Workaround:

  1. Run a quick Mean-Centering PLS (or any PLS) without perm/boot test (because we want do it quickly).
  2. Load result file, and look for fields looks like *coord (e.g. st_coords in fMRI result) and *dim (e.g. st_dims in fMRI).
  3. Type in the following commands (using st_coords & st_dims as example):

img=squeeze(zeros(st_dims));

img(st_coords)=1;

nii=make_nii(img);

view_nii(nii);

That is the way to visualize the included voxels across participants.

 



Untitled Post
vmclelland
Posted on 11/19/13 21:57:02
Number of posts: 11
vmclelland replies:

Thank you very much! I will try this tomorrow :)



Untitled Post
vmclelland
Posted on 11/20/13 13:32:15
Number of posts: 11
vmclelland replies:

Thanks Jimmy - those commands worked perfectly! I tried saving this image as a .nii file and overlaying it on a template image in MRIcron, but the resulting .nii image was very very small (seemingly not in MNI space like the functional images are). Do you happen to know if there is any way to correct this so that I can overlay it properly?



Untitled Post

I'm Online
jshen
Posted on 11/20/13 14:29:40
Number of posts: 291
jshen replies:

quote:

Thanks Jimmy - those commands worked perfectly! I tried saving this image as a .nii file and overlaying it on a template image in MRIcron, but the resulting .nii image was very very small (seemingly not in MNI space like the functional images are). Do you happen to know if there is any way to correct this so that I can overlay it properly?

This is because the voxel size of your raw image for PLS is larger than that in your template image. The following workaround should work:

  1. When you use "make_nii" to create binary image, include the originator (e.g. st_origin or something like this).
  2. Get voxel size from the template image (call it voxel_size), and get dimension size from the template image (call it dims).
  3. Run command:  reslice_nii('binary.nii', 'new_binary.nii', voxel_size)
  4. If the dims of 'new_binary.nii' is larger than or equal to the dims of 'template.nii' in all x, y, and z direction, that is okay. Otherwise, pad your 'new_binary.nii' with 0.
  5. Now, centered from originator, check how many voxels in 'new_binary.nii' should be cut in all six directions (left, right, front, rear, up, down), in order to match 'template.nii'.
  6. Run command clip_nii.m to clip 'new_binary.nii', and save it to 'new2_binary.nii'.

If you overlay 'new2_binary.nii' to 'template.nii', they should match.

The above steps seems overwhelming, but it is not that difficult. I like to expand things into very details so you can follow.

Please let me know if I still did not express myself clearly.

 



Untitled Post

I'm Online
jshen
Posted on 11/20/13 14:59:43
Number of posts: 291
jshen replies:

One more word: Please don't get surprised if you find some of the brain voxels are out of the scalp boundary.

Because the subjects data are real data, and the template data is ideal data, there could be some discrepancies between these two.

However, if your template data was specially tailored and was only built from the selected subjects, all brain voxels should be inside the boundary.

 



Untitled Post
vmclelland
Posted on 11/20/13 21:34:59
Number of posts: 11
vmclelland replies:

Hi Jimmy,

Thanks again for all your help, and sorry for all the questions! - I got to the clip_nii stage but have encountered this error:

??? Attempt to reference field of non-structure array.

Error in ==> clip_nii at 39
   dims = abs(nii.hdr.dime.dim(2:4));

I'm sure I've done something wrong here, and you might need more details to help. The dimensions of the resliced image were very large [1405 2357 811], with the origin being [27 38 18] and so I entered the following:

option.cut_from_L = 24

option.cut_from_R = 1201
option.cut_from_P = 2105
option.cut_from_A = 35
option.cut_from_I = 616
option.cut_from_S = 14

I then entered:

nii = 'NewFunctionalCoverage.nii' %this is the name of the resliced image

and nii = clip_nii(nii, option)

I'm still a MATLAB beginner so am sure I've just done something silly. If you have any insight I would be very grateful!



Untitled Post

I'm Online
jshen
Posted on 11/20/13 22:04:53
Number of posts: 291
jshen replies:

The originator should be at least close to the middle of L-R direction. Therefore, dimension of [1405 2357 811] with originator of [27 38 18] is obviously wrong.

Please upload your template.nii and the original binary.nii that you obtained this morning to somewhere that I can have access (e.g. dropbox), and post the link here. I will look into it tomorrow, and post the detail script here.

 



Untitled Post
vmclelland
Posted on 11/20/13 22:14:58
Number of posts: 11
vmclelland replies:

Thank you so much - sorry for not being able to do it correctly!

Here is the original binary image:

https://www.dropbox.com/s/fposzcy48kn94ti/FunctionalBrainCoverage.nii

Here is the template:

https://www.dropbox.com/s/mw4hwc5mak0jxwk/ch2bet.nii

Here is the binary image made with the origin:

https://www.dropbox.com/s/plqvv9glnyh0isk/FunctionalCoverageOrigin.nii



Untitled Post

I'm Online
jshen
Posted on 11/21/13 00:06:50
Number of posts: 291
jshen replies:

I just took a quick look, and here's the answer:

  1. When you use "make_nii.m", make sure that the 2nd argument is voxel_size and the 3rd argument is originator. In "FunctionalCoverageOrigin.nii", you obviously put originator into the 2nd argument. In order to get familiared with NIfTI and Analyze image data manipulation in detail, please visit:
    • http://research.baycrest.org/~jimmy/NIfTI
  2. When I compare voxel_size between "FunctionalBrainCoverage.nii" and "ch2bet.nii", they are all [1 1 1]. Since their dimensions are different, one of them must be wrong. In order to use template image "ch2bet.nii" as reference, let's assume that "FunctionalBrainCoverage.nii" is wrong. Now, please use "view_nii" to open both, and switch both "Axes Unit" to "Millimeter". You have to manually compare the boundary of the brain region, and figure out the ratio between them. You will find that the coords displayed in [x y z] at crosshair for "ch2bet.nii" is about 2.7 larger than those for "FunctionalBrainCoverage.nii".
  3. Download http://www.rotman-baycrest.on.ca/~jimmy/pad_nii.m, and save it into "plsgui" folder.
  4. Now, run the following commands: (please copy them to your MATLAB command window, and they will work)

nii = load_nii('FunctionalBrainCoverage.nii');

nii=make_nii(nii.img, [2.7 2.7 2.7], [27 38 18]);

save_nii(nii,'binary.nii');

reslice_nii('binary.nii', 'binary2.nii', [1 1 1]);

b=load_nii('binary2.nii');

t=load_nii('ch2bet.nii');

b_org=b.hdr.hist.originator(1:3)

b_dim=b.hdr.dime.dim(2:4)

t_org=t.hdr.hist.originator(1:3)

t_dim=t.hdr.dime.dim(2:4)

% Since b_dim is smaller than t_dim, we have to pad it rather than clip it:

opt.pad_from_L=t_org(1)-b_org(1);

opt.pad_from_R=(t_dim(1)-t_org(1))-(b_dim(1)-b_org(1));

opt.pad_from_P=t_org(2)-b_org(2) ;

opt.pad_from_A=(t_dim(2)-t_org(2))-(b_dim(2)-b_org(2));

opt.pad_from_I=t_org(3)-b_org(3);

opt.pad_from_S=(t_dim(3)-t_org(3))-(b_dim(3)-b_org(3));

b2=pad_nii(b,opt);

save_nii(b2,'binary2.nii');  % if you overlay binary2.nii to template, they should match

% As a matter of fact, you don't need MRIcron, and you can view result immediately via "view_nii.m":

t.img(b2.img>0) = 255;

view_nii(t);

 



Untitled Post
vmclelland
Posted on 11/21/13 12:04:41
Number of posts: 11
vmclelland replies:

Hi Jimmy, 

Thanks for spotting what I'd done wrong, I was wondering why it was so huge!

I've done what you suggested and it all works perfectly now, it overlays just as it should. Thank you so much for all your time and help, especially for responding so quickly, it's very much appreciated!

Victoria




Login to reply to this topic.

  • Keep in touch

Enter your email above to receive electronic messages from Baycrest, including invitations to programs and events, newsletters, updates and other communications.
You can unsubscribe at any time.
Please refer to our Privacy Policy or contact us for more details.

  • Follow us on social
  • Facebook
  • Instagram
  • Linkedin
  • Pinterest
  • Twitter
  • YouTube

Contact Us:

3560 Bathurst Street
Toronto, Ontario
Canada M6A 2E1
Phone: (416) 785-2500

Baycrest is an academic health sciences centre fully affiliated with the University of Toronto