Duke-UNC Brain Imaging and Analysis Center
BIAC Forums | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password   Forgot your Password?
 All Forums
 Support Forums
 Analysis Software Support
 Adding ROIS to Overlay from a script
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ken.roberts
Junior Member

26 Posts

Posted - Apr 25 2003 :  11:58:09 AM  Show Profile  Reply with Quote
Hi.

I would like to produce a three color graph from a script, and as far as I can tell, the easiest way to do this is not with colormaps or anything like that, but with ROI's. So, I want the areas to be colored:

yellow- exceeds thresholds 1 and two respectively on maps 1 and 2
red- exceeds threshold 1 from map 1 only
blue- exceeds threshold 2 from map 2 only

Here is the code I am using, and the error seems to come from adding rois that do not have roi.val set. I tried it with and without the roi.color lines, and with and without the 'ClearROIs' command. The isroi check works.

Is there anything I am doing wrong? I also have the BIAC 2.2 package.


adc_t = readmr('070301_AdcAA_Shifted6s_Map_1-2.T', 64, 64, 6, 'float');
bold_t = readmr('070301_Bold_Shifted6s_Map_1-2.T', 64, 64, 6, 'float');

%interpolate to high resolution
[xx, yy, zz] = ndgrid(0:(1/63):1, 0:(1/63):1, 0:(1/5):1);
[xxi, yyi, zzi] = ndgrid(0:(1/255):1, 0:(1/255):1, 0:(1/5):1);
adc_t = trilinear(xx, yy, zz, adc_t, xxi, yyi, zzi);
bold_t = trilinear(xx, yy, zz, bold_t, xxi, yyi, zzi);
clear('xx', 'yy', 'zz', 'xxi', 'yyi', 'zzi');

bold_thresh = 3;
    adc_thresh = 3;

% create rois
a_mask = adc_t > adc_thresh;
b_mask = bold_t > bold_thresh;
both_mask = a_mask & b_mask;

adc_roi = mask2roi(a_mask-both_mask);
%adc_roi.color = [1 0 0];
bold_roi = mask2roi(b_mask-both_mask);
%bold_roi.color = [0 0 1];
both_roi = mask2roi(both_mask);
%both_roi.color = [1 1 0];


isroi([adc_roi, bold_roi, both_roi])
clear('a_mask', 'b_mask', 'both_mask');

% show data 
b = readmr('/gidata2/NVtiming/Raw_Data/070301/anat/series003/mr5c_20020703_41122_003_00_00001.img', 256, 256, 6, 'volume');
b = flipdim(b, 2);
overlay2(b, [], [], gray(192), redpos(16), bluneg(16), [50 1500]);
%overlay2('ClearROIs');
overlay2('loadrois', gcf, [adc_roi, bold_roi, both_roi]);


If it helps, the error I get is:


???  In an assignment  A(I) = B, the number of elements in B and
 I must be the same.

Error in ==> /usr/BIAC/BIAC/mr/roifuse.m
On line 20  ==>         fusedData(ind)=ROIs(r).val;

Error in ==> /usr/BIAC/BIAC/mr/overlay2.m
On line 827  ==>     sliceData=roifuse(sliceData,img,imgPos,ROIs);

Error in ==> /usr/BIAC/BIAC/mr/overlay2.m (newROI)
On line 1492  ==> overlay2('GUISlider');

Error in ==> /usr/BIAC/BIAC/mr/overlay2.m
On line 283  ==>   newROI(newROIs,ROIs,ROIVals,ROIColors,imgWin,params);

Error in ==> /gidata2/NVtiming/NVtiming/analysis/070301/mrtest/analyze_data.m
On line 78  ==> overlay2('loadrois', gcf, [adc_roi, bold_roi, both_roi]);


Thank you,

Ken

Woldorff Lab
Center for Cognitive Neuroscience
(919) 668-1334

mbudde
Starting Member

USA
9 Posts

Posted - Apr 25 2003 :  12:42:17 PM  Show Profile  Visit mbudde's Homepage  Reply with Quote
Ken,

I've encountered this problem once before, and I just set some arbitrary value for the roi.val and it worked. just like you did with the roi.color line, add in an roi.val line. "roi.val = 10;" I honestly don't think the number will matter. As far as I know, overlay2 can deal with rois with the same .val number.

matt
Go to Top of Page

charles.michelich
BIAC Alum

USA
183 Posts

Posted - Apr 25 2003 :  12:58:43 PM  Show Profile  Reply with Quote
Ken,

I found and fixed the bug in overlay2. I put the fix in the main MATLAB distribution at:
\\Gall\Programs\MATLAB\BIAC\

You can also get just the fix from:
\\Gall\Programs\MATLAB\BIAC_ver2.2_Patches\

(See: http://www.biac.duke.edu/forums/topic.asp?TOPIC_ID=86)

On a separate note, you can use the function scale3 to interpolate your t-maps to a higher resolution instead of using trilinear directly. Note that scale3 also uses trilinear to do the interpolation.

Enjoy,
Chuck


Edited by - charles.michelich on May 02 2003 10:01:14 AM
Go to Top of Page

gunes
BIAC Alum

45 Posts

Posted - Apr 25 2003 :  1:46:36 PM  Show Profile  Reply with Quote
Hi Ken,

I noticed that you are flipping the anatomical fmri, but not 'Bin. T'in your script. It may be a problem unless your are doing purposely.

Is the slice thinkness of your anatomicals the same as the slice thinkness of the functionals? If it is, the following will be true. Otherwise, you have to multiply the right number while using scale3.

adc_t = flipdim(scale3(readmr('070301_AdcAA_Shifted6s_Map_1-2.T', 64, 64, 6, 'float'),4,4,1),2);

Good luck.

Gunes

Go to Top of Page

ken.roberts
Junior Member

26 Posts

Posted - Apr 25 2003 :  2:32:19 PM  Show Profile  Reply with Quote
Thank you for your comments. Ill grab the fixes from the current directory, and look into the scale3 function.

The flipping of the anatomicals alone is intentional, and the anatomicals were acquired with the same slice prescription as the functionals. The anatomical images were acquired before the DICOM system was set up, so that may be why they need to be flipped.

Ken

Woldorff Lab
Center for Cognitive Neuroscience
(919) 668-1334
Go to Top of Page

charles.michelich
BIAC Alum

USA
183 Posts

Posted - Apr 25 2003 :  2:47:42 PM  Show Profile  Reply with Quote
Ken,

You may want to double check on why you are flipping the base image. You are doing an flip in the Y dimension (A-P for axials) so it should be visually obvious if this flip is correct. Images series exported from the scanner should have the same orientation regardless of if they are exported as DICOM or Signa5 images.

Chuck

Edited by - charles.michelich on Apr 25 2003 4:24:34 PM
Go to Top of Page

ken.roberts
Junior Member

26 Posts

Posted - Apr 25 2003 :  3:30:59 PM  Show Profile  Reply with Quote
Actually, I double checked this, and the images are in DICOM, they were converted to .img files with the free software program MRIcro (which may have something to do with this). The pulse sequence is not the standard FSPGR, it is FSE. Anyway, to take a closer look at this, I executed the commands:


v = readmr('mr5c_20020703_41122_003_00_00001.img', 256, 256, 6, 'volume');
overlay2(v)
overlay2(flipdim(v, 1));
overlay2(flipdim(v, 2));
overlay2(flipdim(v, 3));


with the result of the first command flipping left-right, the second anterior-posterior, and the third inferior to superior. The left-right flip was pretty obvious because the subject had his head tilted about 10 degrees with respect to the imaging frame.

Using the second command makes the most superior slice "slice 1", and places the brain so that the frontal lobe is at the top of the screen, and the occipital lobe is at the back of the screen. AS for determining the L-R of the brain, a cursory inspection seems as if it is aligned normally (non-Radiological convention), using the property of the anti-clockwise torque of the brain, but it is a lot more difficult to be sure about this compared to the other orientations.

Any suggestions?

Ken

Woldorff Lab
Center for Cognitive Neuroscience
(919) 668-1334
Go to Top of Page

charles.michelich
BIAC Alum

USA
183 Posts

Posted - Apr 25 2003 :  4:23:04 PM  Show Profile  Reply with Quote
Ken,

It sounds like you are working through this quite thoroughly! I have used MRIcro, but have not ever used it to convert DICOM images.

The pulse sequence you use to collect the data should not effect the orientation of the dimensions in-plane. Jim Voyvodic has found that GE images are always oriented as follows when they come off the scanner:
Axial:    X-> R to L, Y-> A to P  (i.e. img(1,1) is the Right-Anterior corner)
Coronal:  X-> R to L, Y-> S to I  (i.e. img(1,1) is the Right-Superior corner)
Sagittal: X-> A to P, Y-> S to I  (i.e. img(1,1) is the Anterior-Superior corner)
The order along the Z dimension depends on the order in which the images were prescribed on the scanner console. Note that these orientations ONLY apply to the original images. Further processing and display programs may reorient or flip the data. Also, the orientation may be wrong if the wrong patient orientation is entered incorrectly at the scanner console!

In your post, you stated that overlay2(flipdim(v,2)) resulted in flipping anterior-posterior (as expected), but later you stated that this command also makes the most superior slice the first slice. A flipdim along the 2nd dimension will not change the order of the 3rd dimension (S-I for axial images). Are you sure that the most superior slice was not the first slice without this flip also?

As for determining which side of the images is right and left, I suggest you go back to the original DICOM images. If you read the original GE DICOM or Signa images into MATLAB using readmr and then display them in overlay2 without any flipping, they will be in radiological convention (i.e. right will be on the left and left will be on the right) for axial and coronal images. You could then compare the original DICOM images to your MRIcro image to determine what the orientation is. Some people here at BIAC have added a little "L" to the original image and then followed the L through the image processing to determine what effect the processing had on the orientation.

Note that while GE's DICOM data currently follows the orientation convention previously mentioned, DICOM supports other conventions therefore data from other vendors or future software from GE may not follow this convention. readmr currently does NOT reorient the data based on the DICOM header, so be careful if you are using data from other vendors.

I hadn't heard of the "property of the anti-clockwise torque of the brain". This seems like an interesting anatomical observation.

Chuck

P.S. In my previous post, I incorrectly stated that the second dimension is R-L for axials and coronals. The first dimension is R-L for axials and coronals (I have now corrected the previous post). The second dimension of your images (axial) is A-P as you correctly observed.

Edited by - charles.michelich on Apr 25 2003 4:37:23 PM
Go to Top of Page

ken.roberts
Junior Member

26 Posts

Posted - Apr 28 2003 :  11:59:09 AM  Show Profile  Reply with Quote
Chuck,

Thank you for you detailed replies. They really helped to figure out what was going wrong. First, using the BIAC program to read in the DICOM images put them in exactly the orientation you specified- the RAS orientation (Right, Anterior, Superior).

Using MRIcro to convert the images puts them so that the slices are in the same order, but the first coordinate increases from Left to Right, and the second from Posterior to Anterior. So, it turns out to be MRIcro that puts the images in a different order. The analyze header does not seem to have any solid convention for orientation, so it is not a faulty implementation of the DICOM format, but rather an incompleteness of the ANALYZE format, as it is used by SPM.

As you pointed out, flipdim(2) should not change the order of the slices. This is also what I observed- I was just unclear in stating that.

Finally, the Yakovlevian anti-clockwise torque of the brain is just a convenient expression that encapsulates three of the major assymetries of the brain-

1- the right frontal pole and left occipital pole are larger and extend further respectively in the anterior and superior directions.

2- the right prefrontal lobe and left occipital lobe extend across the midsagittal plane.

3- the Sylvian fissure rises more quickly on the right side of the brain than on the left side, or in other words the anatomical features surrounding the right Sylvian fissure are torqued forward, relative to the left.

When viewed from the top, these three features make the brain look as if an anti-clockwise torque had been applied.

Ken

Woldorff Lab
Center for Cognitive Neuroscience
(919) 668-1334
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
BIAC Forums © 2000-2010 Brain Imaging and Analysis Center Go To Top Of Page
This page was generated in 0.47 seconds. Snitz Forums 2000