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
 Matlab path
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vinod
Average Member

USA
68 Posts

Posted - Jul 19 2007 :  11:53:01 AM  Show Profile  Visit vinod's Homepage  Reply with Quote
How do I customize my Matlab path on BIAC computers? Usually, I create a startup.m file to the startup work directory but on BIAC machines, I dont have permission to create one. I tried to change the pathdef file to have these permanently but don't have permission to do that either. I don't want to be adding things like user_scripts folder on Gall each time I write a script.

josh.bizzell
BIAC Staff

USA
118 Posts

Posted - Jul 19 2007 :  11:55:07 AM  Show Profile  Reply with Quote
Put your startup.m file in the top level of your user directory (the U: drive), and it should work.
Go to Top of Page

petty
BIAC Staff

USA
453 Posts

Posted - Jul 19 2007 :  11:55:55 AM  Show Profile  Reply with Quote
put a startup.m file in your user drive (U:\), when you start matlab it should find that file.

just add multiple addpath comments in the file.

Edited by - petty on Jul 19 2007 11:57:50 AM
Go to Top of Page

vinod
Average Member

USA
68 Posts

Posted - Jul 19 2007 :  12:05:50 PM  Show Profile  Visit vinod's Homepage  Reply with Quote
Thanks guys, that worked. And Josh beat petty by 48 secs :), but petty had more things to type :)
Go to Top of Page

vinod
Average Member

USA
68 Posts

Posted - Jul 20 2007 :  11:03:57 AM  Show Profile  Visit vinod's Homepage  Reply with Quote
Here is another matlab question:

I have a data matrix which is a 3-d matrix of size 91x109x91 (FSL standard)
I have a bunch of ROI coordinates in a variable coords, dimension = 115x3 corresponding to 115 voxels in my ROI

Without having to loop through each coordinate and extracting the corresponding value from the data matrix, is there an easier way to get the data values for each of the 115 voxels.

I tried ROIdata = data(coords) and ROIdata = data(coords(:,1),coords(:,2),coords(:,3)) but it doesn't do it.
Go to Top of Page

syam.gadde
BIAC Staff

USA
421 Posts

Posted - Jul 20 2007 :  12:36:17 PM  Show Profile  Reply with Quote
A loop is the only way I can think of accessing the multi-dimensional array. Your listed methods won't work. An alternative is to think of the data matrix as a one-dimensional array, and convert your coordinates to indices into that one-dimensional array. If you index a multi-dimensional matrix with a scalar i like this:

data(i)

Then i is treated as an index into the "flattened" data. You can also send a list:

data([i1, i2, i3, i4, i5, i6, ...])

which will return a list of the values at each of those flattened indices. Note that this is different than:

data(i1, i2, i3, i4, i5, i6)

which would be indexing into a 6-D array with a 6-D coordinate.
Go to Top of Page

josh.bizzell
BIAC Staff

USA
118 Posts

Posted - Jul 20 2007 :  3:03:07 PM  Show Profile  Reply with Quote
To further what Syam suggested, you can use the function "sub2ind" to create the scalar index from the coordinates.

>> idx = sub2ind([91,109,91],coordx,coordy,coordz);

However, I believe you'll still have to loop through the coordinates because this function doesn't take array inputs for the coordinates.

-Josh
Go to Top of Page

vinod
Average Member

USA
68 Posts

Posted - Jul 20 2007 :  3:12:46 PM  Show Profile  Visit vinod's Homepage  Reply with Quote
Thanks guys. My instincts were the same too but just wanted to be sure there was no other 'elegant' way to do this.
Go to Top of Page

charles.michelich
BIAC Alum

USA
183 Posts

Posted - Jul 29 2007 :  12:03:02 AM  Show Profile  Reply with Quote
sub2ind does not take an array of coordinates, but it will take vectors of coordinates as inputs. Therefore, an "elegant" way to accomplish your goal is:

voxelData = data(sub2ind(size(data), coord(:,1), coord(:,2), coord(:,3)));
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.38 seconds. Snitz Forums 2000