★ wanayoo — archive 1999 https://github.com/UCL/STIR/pull/135Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Siemens interfile #135

Merged
merged 23 commits into from Feb 14, 2018
Merged

Siemens interfile #135

merged 23 commits into from Feb 14, 2018

Conversation

@paskino
Copy link
Contributor

paskino commented Jan 12, 2018 •

This is a WORK IN PROGRESS PR.

The siemens interfile reader now is called when the parser finds the specific field %sms-mi version number in the header.

paskino added 2 commits Dec 19, 2017
allows selection of appropriate reader based on the presence of a
particular field in the header: %sms-mi version number.
paskino added 2 commits Jan 16, 2018
TODO:
number of dimensions: must be increased by 1.
applied_correction: should be set to {None}
matrix axis label, must be worked upon
segment table, idem
@paskino
Copy link
Contributor Author

paskino commented Jan 17, 2018

I've added the easy keys. I need help to process the hard ones

  • number of dimensions: must be increased by 1.
  • applied_correction: should be set to {None}
  • matrix axis label
  • segment table
paskino and others added 8 commits Jan 22, 2018
- removed most keywords from InterfileHeaderSiemens that were already in InterfileHeader
- had to create a MinimalInterfileHeader class as there is a clash in the duration keywords between STIR and Siemens Interfile
- read much more, and initialise a ProjDataInfo object correctly

things to do:
- I get a memory error at the end of running list_projdata_info
- actual reading of segment-order etc hasn't been done yet.
- various bits marked with XXX
- inserted segment_sequence
- fix post_processing

still a few XXXX and the sme memory error (probably ZZdeallocation of image_durations)
- fixed timing keyword type
- added energy window parsing
- added check on compression

TODO:
- expand to listmode, norm and images
@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 1, 2018

@paskino, this should now work ok. we'll need to start on listmode...

@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 1, 2018

@paskino, possibly you could some more innocent keys, such that we don't get all the warnings? Could give them a no-op action at the moment.

@paskino
Copy link
Contributor Author

paskino commented Feb 1, 2018

will do

- split InterfilePDFSSiemensHeader into 2 as there are a lot of common keywords
- fixed a few small things in the PDFS part
- construct ProjDataInfo after post_processing all keys.
- fix 'data_offset_in_bytes' for listmode (use a non-vectored key)
@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 1, 2018

ok. possibly ready now :-;

Most unparsed keywords should go in InterfileRawDataHeaderSiemens (ok, those that don't start with % should probably go to InterfileHeader, but we can move that later). Here's a list that has to go into *PDFS*:

> %coincidence window width (ns):=5.85938
> %image duration from timing tags (msec):=900008

And here are those for the *Listmode*:

< %LM event and tag words format (bits):=32
< %SMS-MI header name space:=PETLINK bin address

< %preset type:=time
< %preset unit:=seconds
< %preset value:=900
< %singles polling interval (sec):=2
< %singles polling method:=instantaneous
< %singles scale factor:=8
< %time_sync:=25934299
< %timing tagwords interval (msec):=1
< %total listmode word counts:=331257106
< %total number of singles blocks:=224
< PET scanner type:=cylindrical
< bin size (cm):=0.20445
< distance between rings (cm):=0.40625
< transaxial FOV diameter (cm):=59.6
< gantry crystal radius (cm):=32.8
< septa state:=none

again, use a no_op for now.

 add_key("keyword" , KeyArgument::NONE, &KeyParser::do_nothing); 
@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 1, 2018

@evgueni-ovtchinnikov could you try this with the original header (not the *.STIR). That should be the only change you have to make

@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 1, 2018

for future reference: the listmode header does not contain the following

> image data byte order:=LITTLEENDIAN
> !image relative start time (sec):=0.0
> number of dimensions:=3
> matrix axis label[1]:=bin
> matrix axis label[2]:=projection
> matrix axis label[3]:=plane
> matrix size[1]:=344
> matrix size[2]:=252
> matrix size[3]:=4084
> scale factor (degree/pixel) [2]:=0.714286
> scale factor (mm/pixel) [1]:=2.0445
> scale factor (mm/pixel) [3]:=2.03125

These are nevertheless initialised/checked in InterfileRawDataHeaderSiemens, so I had to put in a somewhat ugly hack to avoid the listmode parsing erroring out...

@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 1, 2018

I'm not sure if norm files need a change. Please try. It might be that BinNormalisationFromECAT8 needs to/could use InterfileHeaderSiemens

@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 1, 2018

gcc on Travis complains as follows

/home/travis/build/UCL/STIR/src/IO/InterfileHeaderSiemens.cxx:67:83: error: ‘stir::PatientPosition::PositionValue’ is not a class or namespace
   for (int patient_position_index = 0; patient_position_index <= PatientPosition::PositionValue::unknown_position; ++patient_position_index)

This is despite

class PatientPosition
{
 public:
  //! enum specifying if the patient is scanned with the head first in the gantry, or the feet.
  enum OrientationValue
  { head_in, feet_in, other_orientation, unknown_orientation };
  //! enum specifying on what side the patient is lying on
  /*! \a prone is face-downward, \a left is lying on the left side */
  enum RotationValue
  { supine, prone, right, left, other_rotation, unknown_rotation };

  //! enum using DICOM abreviations
  /*! See Dicom C.7.3.1.1.2 */
  enum PositionValue
  {
    HFS, //!< Head First-Supine
     <snip>
    unknown_position
  };

Clang is happy with this, so is Visual Studio 2015. Anyone any ideas?

@evgueni-ovtchinnikov
Copy link
Collaborator

evgueni-ovtchinnikov commented Feb 2, 2018

listmode_to_sinograms.py works fine with list.l.hdr (still lots of warnings though)

@evgueni-ovtchinnikov
Copy link
Collaborator

evgueni-ovtchinnikov commented Feb 2, 2018

as_ecat8.py also works fine with norm.n.hdr (had to correct line endings since I am on Windows)

@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 2, 2018

list of keywords for the PDFS that need to be parsed.

The study date ones are interesting. It seems that the KeyParser truncates

%study date (yyyy:mm:dd):=2017:03:27

due to the :. That seems a bug. Might not be easy to fix so I think it needs a separate issue.

%comment
%sms-mi header name space
%listmode header file
%listmode data file
%compressor version
%study date (yyyy
%study time (hh
isotope name
isotope gamma halflife (sec)
isotope branching factor
radiopharmaceutical
%tracer injection date (yyyy
%tracer injection time (hh
relative time of tracer injection (sec)
tracer activity at time of injection (bq)
injected volume (ml)
horizontal bed translation
start horizontal bed position (mm)
end horizontal bed position (mm)
start vertical bed position (mm)
%coincidence window width (ns)
gantry tilt angle (degrees)
method of attenuation correction
method of scatter correction
%method of random correction
%decay correction
%decay correction reference date (yyyy
%decay correction reference time (hh
decay correction factor
scatter fraction (%)
scan data type description
total prompts events
total prompts
%total randoms
%total net trues
%image duration from timing tags (msec)
%gim loss fraction
%pdr loss fraction
%detector block singles
%total uncorrected singles rate
@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 2, 2018

List for listmode. Large overlap with the PDFS ones, so the overlapping ones have to be in RawData as mentioned above.

%sms-mi header name space
%study date (yyyy
%study time (hh
isotope name
isotope gamma halflife (sec)
isotope branching factor
radiopharmaceutical
relative time of tracer injection (sec)
tracer activity at time of injection (bq)
injected volume (ml)
%tracer injection date (yyyy
%tracer injection time (hh
horizontal bed translation
start horizontal bed position (mm)
end horizontal bed position (mm)
start vertical bed position (mm)
%bed zero offset (mm)
pet scanner type
transaxial fov diameter (cm)
distance between rings (cm)
gantry tilt angle (degrees)
gantry crystal radius (cm)
bin size (cm)
septa state
%tof mashing factor
%preset type
%preset value
%preset unit
%total listmode word counts
%coincidence list data
%lm event and tag words format (bits)
%timing tagwords interval (msec)
%singles polling method
%singles polling interval (sec)
%singles scale factor
%total number of singles blocks
%time sync
%comment
@rijobro
Copy link
Collaborator

rijobro commented Feb 5, 2018

@evgueni-ovtchinnikov, neither listmode_to_sinograms.py or reconstruct_from_listmode.py are working for me. Both of them show parser warnings (don't think the problem is related to this) and then Segmentation fault: 11. Any ideas?

@evgueni-ovtchinnikov
Copy link
Collaborator

evgueni-ovtchinnikov commented Feb 5, 2018

No idea. What are your input files?

@rijobro
Copy link
Collaborator

rijobro commented Feb 5, 2018

blank (default)

@evgueni-ovtchinnikov
Copy link
Collaborator

evgueni-ovtchinnikov commented Feb 6, 2018

@rijobro I presume you are running SIRF on Mac? Everything works fine on Windows/CentOS/Ubuntu.

@rijobro
Copy link
Collaborator

rijobro commented Feb 6, 2018

I had a problem that was due to the example files (list.l.hdr.STIR and/or list.l). This was solved simply by replacing the files with other example data.

I then came across other problems that @KrisThielemans managed to sort out.

We can have a look at the code on Friday if you want.

@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 8, 2018

Current code will segfault when using a converted hdr for a listmode file. Reason is that the data offset in bytes has different conventions in STIR and Siemens Interfile. When using a converted file, the Siemens fileds are still there, so the code tries to read it as a Siemens file, and it then crashes (because of a problem in KeyParser). Not sure how to fix this, except by putting up a huge warning, and adapt the convert* script to remove the Siemens-related keyword.

@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 13, 2018 •

New issues created #149 and #148 for things noted above. Will fix those in separate PRs.

I think that means the things that need doing here

  • change convertSiemensToInterfile.sh to just write an message and exit with 1
  • add some info in doc/Release3.1.htm and doc/UsersGuide.tex
  • add above keywords as dummies
@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 13, 2018

thanks. can you do the other 2 items on the checklist? then we merge

@KrisThielemans
Copy link
Collaborator

KrisThielemans commented Feb 13, 2018

by the way, I intend to squash-merge this (unless somebody volunteers to clean up the history)

updated release info 3.1
updated bash script for Siemens interfile
@paskino
Copy link
Contributor Author

paskino commented Feb 13, 2018

I wouldn't quite know where to put info in the user's guide.

I've ticked the checklist

@KrisThielemans KrisThielemans merged commit 09d490c into UCL:master Feb 14, 2018
0 of 3 checks passed
0 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
Codacy/PR Quality Review Hang in there, Codacy is reviewing your Pull request.
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
@KrisThielemans KrisThielemans deleted the SyneRBI:siemens_interfile branch Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.