matlab - Extracting the coordinates associated with voxels from a text file and store in a .mat file -


i have text file formatted follows:

fileversion: 1   timepoint:   1  nrofrois:    3  roi:         1 nrofvoxels:  7  43  22   5    766  45  22   5    837  42  23   5    961  43  23   5    878  44  23   5    760  43  24   5    889  43  25   5    929 avgvalue: 860.000000  roi:         2 nrofvoxels:  7  20  21   5    668  22  21   5    727  23  21   5    748  24  21   5    727  23  22   5    810  23  23   5    868  24  23   5    764 avgvalue: 759.000000 

i have extract coordinates (only first 3 columns) of voxels associated every roi , save them in different .mat file, respectively. example, after extracting coordinates of roi: 1, should have coordinates (first 3 colums) in .mat file (and roi 2 in different .mat file):

 43 22 5  45 22 5  42 23 5  43 23 5  44 23 5  43 24 5  43 25 5 

can please me achieve using matlab? open file , read line-by-line.

here matlab code, read coordinates associated roi 1:

filename = 'test.ert'; fid = fopen(filename);  r_lines = 9; k = 1:r_lines     fgetl(fid); end  elines = 7; = 1:elines     tline = fgetl(fid);     tline = tline(:, 1:end-7); disp(tline) end  fclose(fid) 

and, here output:

43  22   5 45  22   5 45  22   5 45  22   5 45  22   5 45  22   5 45  22   5 

how save output .mat file?

have @ textread function in matlab documentation. possible read text file in formatted way, e.g. if set format '%u %u %u', values need read. can store them in vectors if want.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -