Thread Subject: sagittal slice from a txt file

Subject: sagittal slice from a txt file

From: Nico zanette

Date: 10 Feb, 2009 11:21:02

Message: 1 of 7

Hello
I'm in trouble, I need to obtain a MR image from a txt file.
The file contains a single column of data, with each row representing a different voxel in the grid. The data file was generated using the following ordering of grid cells:

for kk=1:s3
  for jj=1:s2
    for ii=1:s1
      fprintf(fid,'%1.1f\n',ARRAY(ii,jj,kk));
    end
  end
end
where the dimension of ARRAY is [s1 x s2 x s3]

I need to transform this file into a 3d image. After this i need to take sagittal slices from the 3d image.

Somebody can help me?

Thanks.

Subject: sagittal slice from a txt file

From: David

Date: 10 Feb, 2009 12:11:02

Message: 2 of 7

"Nico zanette" <zannakill@hotmail.com> wrote in message <gmrnuu$hdo$1@fred.mathworks.com>...
> Hello
> I'm in trouble, I need to obtain a MR image from a txt file.
> The file contains a single column of data, with each row representing a different voxel in the grid. The data file was generated using the following ordering of grid cells:
>
> for kk=1:s3
> for jj=1:s2
> for ii=1:s1
> fprintf(fid,'%1.1f\n',ARRAY(ii,jj,kk));
> end
> end
> end
> where the dimension of ARRAY is [s1 x s2 x s3]
>
> I need to transform this file into a 3d image. After this i need to take sagittal slices from the 3d image.
>
> Somebody can help me?
>
> Thanks.

well, i would guess the first step is to reverse the writing process to read the data back into the workspace. Then its just a simple matter of displaying it however you want.

Subject: sagittal slice from a txt file

From: Nico zanette

Date: 10 Feb, 2009 13:48:02

Message: 3 of 7

"David" <dave@bigcompany.com> wrote in message <gmrqsl$lnt$1@fred.mathworks.com>...
> "Nico zanette" <zannakill@hotmail.com> wrote in message <gmrnuu$hdo$1@fred.mathworks.com>...
> > Hello
> > I'm in trouble, I need to obtain a MR image from a txt file.
> > The file contains a single column of data, with each row representing a different voxel in the grid. The data file was generated using the following ordering of grid cells:
> >
> > for kk=1:s3
> > for jj=1:s2
> > for ii=1:s1
> > fprintf(fid,'%1.1f\n',ARRAY(ii,jj,kk));
> > end
> > end
> > end
> > where the dimension of ARRAY is [s1 x s2 x s3]
> >
> > I need to transform this file into a 3d image. After this i need to take sagittal slices from the 3d image.
> >
> > Somebody can help me?
> >
> > Thanks.
>
> well, i would guess the first step is to reverse the writing process to read the data back into the workspace. Then its just a simple matter of displaying it however you want.

In the command window I load the txt file withe the LOAD command, but I don't know how to obtain the 3d image. Using the PLOT command, the mathlab give me only a 3d figure totally blank, only with the x,y,z axys. I'm sure that the txt file is really load by mathlab.

Subject: sagittal slice from a txt file

From: David

Date: 10 Feb, 2009 13:52:01

Message: 4 of 7

"Nico zanette" <zannakill@hotmail.com> wrote in message <gms0ii$qb9$1@fred.mathworks.com>...
> "David" <dave@bigcompany.com> wrote in message <gmrqsl$lnt$1@fred.mathworks.com>...
> > "Nico zanette" <zannakill@hotmail.com> wrote in message <gmrnuu$hdo$1@fred.mathworks.com>...
> > > Hello
> > > I'm in trouble, I need to obtain a MR image from a txt file.
> > > The file contains a single column of data, with each row representing a different voxel in the grid. The data file was generated using the following ordering of grid cells:
> > >
> > > for kk=1:s3
> > > for jj=1:s2
> > > for ii=1:s1
> > > fprintf(fid,'%1.1f\n',ARRAY(ii,jj,kk));
> > > end
> > > end
> > > end
> > > where the dimension of ARRAY is [s1 x s2 x s3]
> > >
> > > I need to transform this file into a 3d image. After this i need to take sagittal slices from the 3d image.
> > >
> > > Somebody can help me?
> > >
> > > Thanks.
> >
> > well, i would guess the first step is to reverse the writing process to read the data back into the workspace. Then its just a simple matter of displaying it however you want.
>
> In the command window I load the txt file withe the LOAD command, but I don't know how to obtain the 3d image. Using the PLOT command, the mathlab give me only a 3d figure totally blank, only with the x,y,z axys. I'm sure that the txt file is really load by mathlab.

what are the dimensions of the data when you have loaded it back into the workspace? and exactly what plot command do you use?

Subject: sagittal slice from a txt file

From: Nico zanette

Date: 10 Feb, 2009 14:15:03

Message: 5 of 7

"David" <dave@bigcompany.com> wrote in message <gms0q1$c6p$1@fred.mathworks.com>...
> "Nico zanette" <zannakill@hotmail.com> wrote in message <gms0ii$qb9$1@fred.mathworks.com>...
> > "David" <dave@bigcompany.com> wrote in message <gmrqsl$lnt$1@fred.mathworks.com>...
> > > "Nico zanette" <zannakill@hotmail.com> wrote in message <gmrnuu$hdo$1@fred.mathworks.com>...
> > > > Hello
> > > > I'm in trouble, I need to obtain a MR image from a txt file.
> > > > The file contains a single column of data, with each row representing a different voxel in the grid. The data file was generated using the following ordering of grid cells:
> > > >
> > > > for kk=1:s3
> > > > for jj=1:s2
> > > > for ii=1:s1
> > > > fprintf(fid,'%1.1f\n',ARRAY(ii,jj,kk));
> > > > end
> > > > end
> > > > end
> > > > where the dimension of ARRAY is [s1 x s2 x s3]
> > > >
> > > > I need to transform this file into a 3d image. After this i need to take sagittal slices from the 3d image.
> > > >
> > > > Somebody can help me?
> > > >
> > > > Thanks.
> > >
> > > well, i would guess the first step is to reverse the writing process to read the data back into the workspace. Then its just a simple matter of displaying it however you want.
> >
> > In the command window I load the txt file withe the LOAD command, but I don't know how to obtain the 3d image. Using the PLOT command, the mathlab give me only a 3d figure totally blank, only with the x,y,z axys. I'm sure that the txt file is really load by mathlab.
>
> what are the dimensions of the data when you have loaded it back into the workspace? and exactly what plot command do you use?

>> whos
  Name Size Bytes Class

  ARRAY 20x4x2 1280 double array
  ans 1x1 8 double array
  ii 1x1 8 double array
  index 1x1 8 double array
  jj 1x1 8 double array
  kk 1x1 8 double array
  mtype 27842650x1 222741200 double array
  s1 1x1 8 double array
  s2 1x1 8 double array
  s3 1x1 8 double array

Grand total is 27842818 elements using 222742544 bytes

the txt file is called mtype, it is such a big file.
I try, simply, with >>plot (mtype);
i try also by plotting only x or y axys with no results.

Subject: sagittal slice from a txt file

From: David

Date: 10 Feb, 2009 15:12:01

Message: 6 of 7

"Nico zanette" <zannakill@hotmail.com> wrote in message <gms257$b9t$1@fred.mathworks.com>...
> Name Size Bytes Class
> mtype 27842650x1 222741200 double array
> I try, simply, with >>plot (mtype);
> i try also by plotting only x or y axys with no results.

well, i am dissappointed in matlab's plot function for not being able to figure out just what you wanted. it looks like you'll have to do some more work to format the data so it can figure it out. First you'll have to reverse the process that put the data into the file in a single column. check out the 'reshape' function to convert to the original x,y,z sizes. Then you can start to process slices and do plots with the 'surf' or maybe 'contour' functions instead of 'plot'.

Subject: sagittal slice from a txt file

From: Nico zanette

Date: 10 Feb, 2009 15:40:17

Message: 7 of 7

"David" <dave@bigcompany.com> wrote in message <gms5g1$rj7$1@fred.mathworks.com>...
> "Nico zanette" <zannakill@hotmail.com> wrote in message <gms257$b9t$1@fred.mathworks.com>...
> > Name Size Bytes Class
> > mtype 27842650x1 222741200 double array
> > I try, simply, with >>plot (mtype);
> > i try also by plotting only x or y axys with no results.
>
> well, i am dissappointed in matlab's plot function for not being able to figure out just what you wanted. it looks like you'll have to do some more work to format the data so it can figure it out. First you'll have to reverse the process that put the data into the file in a single column. check out the 'reshape' function to convert to the original x,y,z sizes. Then you can start to process slices and do plots with the 'surf' or maybe 'contour' functions instead of 'plot'.

ok, thanks!
I will try with the reshape and the surf command.
If I've been albe to obtain something i will tell you.

Thanks a lot

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com