SyneRBI / SIRF

Main repository for the CCP SynerBI software
http://www.ccpsynerbi.ac.uk
Other
60 stars 29 forks source link

Randoms, norm, attenuation, scatter for Siemens mMR. #54

Closed evgueni-ovtchinnikov closed 6 years ago

evgueni-ovtchinnikov commented 6 years ago

running

int main() { std::string input_filename = "C:/Users/wps46139/Documents/GitHub/SIRF/data/examples/PET/norm.n.hdr.STIR"; shared_ptr sptr_n(new BinNormalisationFromECAT8(input_filename)); return 0; }

produces a lot of warning messages:

WARNING: KeyParser warning: unrecognized keyword: pet data type WARNING: KeyParser warning: unrecognized keyword: %data format WARNING: KeyParser warning: unrecognized keyword: number format WARNING: KeyParser warning: unrecognized keyword: number of bytes per pixel WARNING: KeyParser warning: unrecognized keyword: %raw normalization scans description WARNING: KeyParser warning: unrecognized keyword: %number of normalization scans WARNING: KeyParser warning: unrecognized keyword: %normalization scan WARNING: KeyParser warning: unrecognized keyword: isotope name WARNING: KeyParser warning: unrecognized keyword: radiopharmaceutical WARNING: KeyParser warning: unrecognized keyword: total prompts WARNING: KeyParser warning: unrecognized keyword: %total randoms WARNING: KeyParser warning: unrecognized keyword: number of time frames WARNING: KeyParser warning: unrecognized keyword: image duration (sec) WARNING: KeyParser warning: unrecognized keyword: %number of buckets WARNING: KeyParser warning: unrecognized keyword: %total uncorrected singles rate WARNING: KeyParser warning: unrecognized keyword: %normalization components description WARNING: KeyParser warning: unrecognized keyword: %number of normalization components WARNING: KeyParser warning: unrecognized keyword: %normalization component WARNING: KeyParser warning: unrecognized keyword: data offset in bytes WARNING: KeyParser warning: unrecognized keyword: number of dimensions WARNING: KeyParser warning: unrecognized keyword: %matrix size WARNING: KeyParser warning: unrecognized keyword: %matrix axis label WARNING: KeyParser warning: unrecognized keyword: %matrix axis unit WARNING: KeyParser warning: unrecognized keyword: %scale factor WARNING: KeyParser warning: unrecognized keyword: %axial compression WARNING: KeyParser warning: unrecognized keyword: %maximum ring difference WARNING: KeyParser warning: unrecognized keyword: number of rings WARNING: KeyParser warning: unrecognized keyword: number of energy windows WARNING: KeyParser warning: unrecognized keyword: %energy window lower level (kev) WARNING: KeyParser warning: unrecognized keyword: %energy window upper level (kev) WARNING: KeyParser warning: unrecognized keyword: %global scanner calibration factor WARNING: KeyParser warning: unrecognized keyword: %scanner quantification factor (bq*s/ecat counts) WARNING: KeyParser warning: unrecognized keyword: %calibration date (yyyy WARNING: KeyParser warning: unrecognized keyword: %calibration time (hh WARNING: KeyParser warning: unrecognized keyword: %cross calibration factor WARNING: KeyParser warning: unrecognized keyword: %data set description WARNING: KeyParser warning: unrecognized keyword: total number of data sets WARNING: KeyParser warning: unrecognized keyword: %data set WARNING: KeyParser warning: unrecognized keyword: end of interfile

and hangs.

The file C:/Users/wps46139/Documents/GitHub/SIRF/data/examples/PET/norm.n.hdr.STIR contains:

!INTERFILE:= %comment:=CPS ECAT8 sinogram common attributes !originating system:=2008 %SMS-MI header name space:=normalization header %SMS-MI version number:=3.4

!GENERAL DATA:= data description:=PET scanner normalization Coefficients !name of data file:=norm.n %expiration date (yyyy:mm:dd):=2099:01:01 %expiration time (hh:mm:ss GMT-05:00):=12:00:00

!GENERAL IMAGE DATA := !type of data := PET

%study date (yyyy:mm:dd):=2017:08:09 %study time (hh:mm:ss GMT+00:00):=07:23:33 imagedata byte order:=LITTLEENDIAN !PET data type:=normalization %data format:=sinogram - expandable from norm components number format:=float number of bytes per pixel:=4

%RAW NORMALIZATION SCANS DESCRIPTION:= %number of normalization scans:=2 %normalization scan [1]:=geometric profile scan %normalization scan [2]:=axial profile scan isotope name [1]:=Ge-68 isotope name [2]:=Ge-68 radiopharmaceutical [1]:=PHARM_TEST radiopharmaceutical [2]:=PHARM_TEST total prompts [1]:=0 total prompts [2]:=606438670 %total randoms [1]:=0 %total randoms [2]:=239382307 number of time frames:=1 !image duration (sec)[1] [1]:=0 number of time frames:=1 !image duration (sec)[1] [2]:=7200 %number of buckets:=12 %total uncorrected singles rate [1]:=0 %total uncorrected singles rate [2]:=0

%NORMALIZATION COMPONENTS DESCRIPTION:= %number of normalization components:=8 %normalization component [1]:=geometric effects %normalization component [2]:=crystal interference %normalization component [3]:=crystal efficiencies %normalization component [4]:=axial effects %normalization component [5]:=paralyzing ring DT parameters %normalization component [6]:=non-paralyzing ring DT parameters %normalization component [7]:=TX crystal DT parameter %normalization component [8]:=additional axial effects data offset in bytes [1]:=0 data offset in bytes [2]:=174752 data offset in bytes [3]:=187136 data offset in bytes [4]:=316160 data offset in bytes [5]:=319508 data offset in bytes [6]:=319764 data offset in bytes [7]:=320020 data offset in bytes [8]:=320056 number of dimensions [1]:=2 number of dimensions [2]:=2 number of dimensions [3]:=2 number of dimensions [4]:=1 number of dimensions [5]:=1 number of dimensions [6]:=1 number of dimensions [7]:=1 number of dimensions [8]:=1 %matrix size [1]:={344,127} %matrix size [2]:={9,344} %matrix size [3]:={504,64} %matrix size [4]:={837} %matrix size [5]:={64} %matrix size [6]:={64} %matrix size [7]:={9} %matrix size [8]:={837} %matrix axis label [1]:={sinogram projection bins,sinogram planes} %matrix axis label [2]:={crystal number,sinogram projection bins} %matrix axis label [3]:={crystal number,ring number} %matrix axis label [4]:={plane number} %matrix axis label [5]:={ring number} %matrix axis label [6]:={ring number} %matrix axis label [7]:={crystal number} %matrix axis label [8]:={plane number} %matrix axis unit [1]:={mm/pixel,mm/pixel} %matrix axis unit [2]:={mm/pixel,mm/pixel} %matrix axis unit [3]:={mm/pixel,mm/pixel} %matrix axis unit [4]:={mm/pixel} %matrix axis unit [5]:={mm/pixel} %matrix axis unit [6]:={mm/pixel} %matrix axis unit [7]:={mm/pixel} %matrix axis unit [8]:={mm/pixel} %scale factor [1]:={2.0445,2.03125} %scale factor [2]:={2.0445,2.0445} %scale factor [3]:={2.0445,4.0625} %scale factor [4]:={2.03125} %scale factor [5]:={4.0625} %scale factor [6]:={4.0625} %scale factor [7]:={2.03125} %scale factor [8]:={2.03125} %axial compression:=11 %maximum ring difference:=60 number of rings:=64 number of energy windows:=1 %energy window lower level (keV) [1]:=430 %energy window upper level (keV) [1]:=610

%GLOBAL SCANNER CALIBRATION FACTOR:= %scanner quantification factor (Bq*s/ECAT counts):=1.98459e+007 %calibration date (yyyy:mm:dd):=2017:08:09 %calibration time (hh:mm:ss GMT+00:00):=07:23:33 %cross calibration factor:=0.96

%DATA SET DESCRIPTION:= !total number of data sets:=1 %data set [1]:={0,,20170809_NEMA_UCL.n} !END OF INTERFILE :=

KrisThielemans commented 6 years ago

hi, all the warnings are related to kewywords which we ignore right now (we should read them at some point. This should happen in BinNormalisationFromECAT8::read_norm_data). This will be at some point fixed via PR https://github.com/UCL/STIR/pull/135.

The "continue to read" hang is something that @paskino observed as well. It must have to do with EOL conventions in the file and PCs. I believe @paskino fixed that in the same PR.

So I think you could switch your STIR_URL and STIR_TAG to use https://github.com/CCPPETMR/STIR/tree/siemens_interfile to resolve the hang.

KrisThielemans commented 6 years ago

I've put a fix the UCL/STIR master such that it will pick up the END OF INTERFILE keyword, which should also resolve your problem.

evgueni-ovtchinnikov commented 6 years ago

instead of WARNING: KeyParser warning: unrecognized keyword: end of interfile

I now get WARNING: read_data: error before reading from stream. ERROR: failed reading 'norm.n%expirationdate(yyyy:mm:dd):=2099:01:01'

the error is apparently due to the different line end in Windows, inserting empty line before %expirationdate eliminates it, but I still get WARNING: read_data: error before reading from stream. ERROR: failed reading 'norm.n'

the error message comes from BinNormalisationFromECAT8::read_norm_data(), looks like the same problem as in STIR #133?

evgueni-ovtchinnikov commented 6 years ago

@bathomas

ERROR: failed reading 'norm.n%expirationdate(yyyy:mm:dd):=2099:01:01'

suggests there was a wrong line ending in the line

!name of data file:=norm.n

in norm.n.hdr.STIR (renamed 20170809_NEMA_UCL.n.hdr.STIR). Please check your converter to STIR header

evgueni-ovtchinnikov commented 6 years ago

fixed filepath bug on CCPPETMR/STIR (after merging UCL/STIR)

KrisThielemans commented 6 years ago

the converter should become obsolete as soon as #56 is complete. let's not attempt to fix it.

evgueni-ovtchinnikov commented 6 years ago

BinNormalisationFromECAT8::read_norm_data creates files eff_out, geom_out and inter_out - debugging?

KrisThielemans commented 6 years ago

Yes. Debugging output. Could make this optional

Kris Thielemans Reader in Medical Imaging Physics UCL


From: evgueni-ovtchinnikov notifications@github.com Sent: Tuesday, January 16, 2018 10:50:11 AM To: CCPPETMR/SIRF Cc: Thielemans, Kris; Assign Subject: Re: [CCPPETMR/SIRF] Randoms, norm, attenuation, scatter for Siemens mMR. (#54)

BinNormalisationFromECAT8::read_norm_data creates files eff_out, geom_out and inter_out - debugging?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://github.com/CCPPETMR/SIRF/issues/54#issuecomment-357923405, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGEUHdElR20T1LBqO_hH5_koOtUZvJ80ks5tLH7jgaJpZM4OZz7E.

evgueni-ovtchinnikov commented 6 years ago

I got this error message when trying to use BinNormalizationFromAttenuationImage::undo:

ForwardProjectByBin: forward_project called with incorrect related_viewgrams. Problem with symmetries!

For set_up, I used template_span11.hs.

Attenuation image comes from 20170809_NEMA_MUMAP_UCL.v.hdr.STIR.

KrisThielemans commented 6 years ago

tcon 19Jan decision is to postpone scatter to v1.1 as it needs more work from Nikos, and then testing

evgueni-ovtchinnikov commented 6 years ago

On tcon 31 we decided to keep randoms in a file. However, in this case on my desktop ListmodeToSinograms::estimate_randoms() takes about 70 sec as opposed to 7 sec in-memory computation. (Interestingly, on my laptop it is 10 sec against 7 sec - must be due to solid-state hard drive).

I suggest for now we do in-memory estimation option with subsequent save to a file (takes 14 sec).

KrisThielemans commented 6 years ago

ok. pretty interesting find! we'll want to investigate this later. stir::ProjData IO seems to be slow in general, maybe due to lots of seeking.

evgueni-ovtchinnikov commented 6 years ago

should we move scatter to 1.1 and close the issue?

KrisThielemans commented 6 years ago

I'm fine to create a seperate issue for scatter and refer to that here. However, we cannot close this yet until we have tested the current code in more detail.

evgueni-ovtchinnikov commented 6 years ago

done enough for 1.0.0