[Gate-users] Output
D.J. van der Laan
d.j.vanderlaan at tnw.tudelft.nl
Fri Jun 1 15:06:03 CEST 2007
Hi Daniel,
Daniel Woodsworth wrote:
> Hi,
>
> I am wondering what the best way is to output data from GATE simulations.
> I am doing SPECT simulations, so for creating projections, I have been
> using the Interfile output, which works really well.
>
> However, for data analysis and processing and numerical calculations,
> obviously it is good to have all the information about order of scatter,
> last object in which scatter occurred etc. etc. This (as far as I can
> tell) is not included in an interfile. So it seems that for this data I
> should use root and/or ascii output (are there any other general purpose
> outputs? is it possible to write directly to binary files?).
It is not possible to write binary files from Gate (except ROOT files
then). It is however not difficult to ad this to Gate, but this would
involve recompiling Gate.
> In the Output
> section of the GATE manual it says that the root files are smaller and
> contain all of the same information that is in the ascii format. I have 2
> questions about this. First, upon running the SPECT benchmark, the
> benchSPECT.root file is 61 MB, while the ascii gateSingles.dat is 6.3 MB.
> How does this relate to the root files being smaller? Does this become
> true for larger data output files?
First of all, I am not an expert on root, so if anybody else knows
better please feel free to correct me.
I dont't know what causes the differences in file size. Perhaps more
information is stored in the root file (hits?)?
> Second, when I load up the root file:
>
> home> root benchSPECT.root
>
> root [0]
> Attaching file benchSPECT.root as _file0...
> root [1] TBrowser t
>
> I only find already processed data, presented as histograms and whatnot.
> Can anyone tell me where to find the raw data, as in the ascii output?
> Since it is compressed, I assume it isn't some form of directly readable
> file. Is it binary? What I am asking for is which file do I use for raw
> input data if I were to write ROOT analysis scripts, and in what format is
> the data written to this file?
All data is present in file, the browser only shows 'summaries' of this
data. The data is stores in trees. I this it is easiest if you have a
look at the root files that come with the benchmarks, to see how you can
acces the data. There is also a lot of documentation on the ROOT website
(http://root.cern.ch/root/doc/RootDoc.html).
Here is a simple example how you can access the energies of all the
singles. (In this case all of the energies are summed.):
{
gROOT->Reset();
// open the file
TFile f("gate.root");
// open the singles directory
TTree *singles = (TTree*)gDirectory->Get("Singles");
// 'connect' the energy veriable to the energy branch of the singles
// Now when the GetEntry(int) method of the singles is called the
// energy belonging to the single can be found in the variable energy
Float_t energy;
singles->SetBranchAddress("energy", &energy);
// loop throough all singles and sum the energies
Int_t nsingles = singles->GetEntries();
Float_t totalenergy = 0;
for (Int_t i = 0; i < nsingles; i++)
{
singles->GetEntry(i);
totalenergy += energy;
}
cout << "Total energy: " << totalenergy << endl;
}
>
> Finally is it recommended to do analysis using 'homemade' (ie. C or C++)
> programs analyzing the ascii output? Or rather using ROOT scripts for the
> root file?
In our group we use Matlab for all data processing. So we use the ASCII
output and process that with Matlab, or sometimes we preprocess it with
routines written in C/C++. That works fine.
The only problem with ASCII can be the file sizes. I don't know if it is
still a problem if the size exceeds 2 GB. However in these cases it is
also possible to process the data while Gate is running using a fifo.
Regards,
Jan
>
> Thanks for the help.
>
> Daniel
>
>
> _______________________________________________
> Gate-users mailing list
> Gate-users at lists.healthgrid.org
> http://lists.healthgrid.org/mailman/listinfo/gate-users
--
D.J. van der Laan
Delft University of Technology
Mekelweg 15, room 2.00.020
2629 JB Delft
The Netherlands
E: d.j.vanderlaan at tudelft.nl
T: +31 15 2783776
F: +31 15 2789011
More information about the Gate-users
mailing list