-
Notifications
You must be signed in to change notification settings - Fork 98
BinNormalisationWithCalibration and set_up(projdataInfo, ExamInfo): #672
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
Conversation
danieldeidda
commented
Aug 26, 2020
- added class for calibration BinNormalisation and calibration factor #446 , decay and branching ration corr need to be derived from there;
- BinNormalisation::set_up() has a new input, exam_info;
- all instances where set_up() is used have been updated;
- BinNormalisation::apply() does not need start_time and end_time as inputs, can be extracted from exam_info BinNormalisation::apply should use timing info from ExamInfo #340 . Nedd to modify undo().
1) added class for calibration, decay and branching ration corr need to be derived from there; 2) BinNormalisation::set_up() has a new input, exam_info; 3) all instances where set_up() is used have been updated; 4) BinNormalisation::apply() does not need start_time and end_time as inputs, can be extracted from exam_info. Nedd to modify undo().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
I have a few smallish comments, but then also a worry (which actually affects some of my "inline" comments). First the comments:
- best to use
set_up(shared_ptr<const ExamInfo>& exam_info_sptr, const shared_ptr<const ProjDataInfo>&)
. Order is then the same as in other places, and it's best to used a ptr as at some pointExamInfo
might become a hierarchy - there's also some in
experimental
(build with it "on", although not all might be included by default) - I thought we said we'd store the actual
calibration_factor
andbranching_ratio
inExamInfo
(certainly thebranching_ratio
should in the future be set by reading the actual sinogram, not the norm file). - I see no reason to have the
BinNormalisationWithCalibration::apply(RelatedViewgrams&
) members.BinNormalisation
will implement it in terms ofget_bin_efficiency
(if there is a reason, we obviously still need to doundo
as you wrote) - we could provide a backwards compatible
apply(ProjData, start, end)
just calling the new one, but making it deprecated. - It is a but strange to remove the
start/end
fromapply(ProjData)
but not the one withRelatedViewgrams
norget_bin_efficiency
. However, I strongly recommend to postpone that to another PR, as really we're mixing 2 things here (i.e. how to set calibration factor, and removing unnecessary start/stop parameters). - will need
set/get_calibration_factor
andset/get_branching_ratio
members (although the latter would be superseded by aset_isotope
presumably)
Notes:
- some of my "inline" comments assumed that
BinNormalisation
was derived fromParsingObject
already, and therefore I suggested calls tobase_type
functions. However but it appears it isn't, so I think you can ignore those comments for now (or put in the extra mile and deriveBinNormalisation
fromParsingObject
after all, as is actually recommended).
Now the worry:
How do we see that this fits in the hierarchy actually? The current set-up seems to imply that if you want to do norm with calibration, you need to set up a "chained" bin normalisation, taking the "calibration" and the "normal" one. This would work, but it would be
- inconvenient for the user as having to set-it up quite verbosely, but more importantly doesn't immediately fit with letting
BinNormalisationFromECAT8
or...GERDF
to read the calibration factor from their input as opposed to the par file. - somewhat inefficient (we'd first get a viewgram, normalise it with normal factors, then multiply with a global factor), as opposed to doing it all in one go.
The alternative approach is to have this a class that actually doesn't have apply/undo
members, but a single get_global_norm_factor()
(or some similar name) that would multiply calibration_factor
, branch_ratio
(and later-on decay
). BinNormalisationFromECAT8
etc would then be derived from this one, but have to call get_global_norm_factor()
themselves in their get_bin_efficiency
(see an alternative below). It would mean modifying those classes though. This might be ok though, as they need to read the calibration factor anyway.
Side note: for the non-stationary scanner (SPECT) case, the decay factor is going to be bin-dependent, so I guess we cannot have a global
factor after all...
I think the 2nd approach is better as ultimately easier for the user (but a bit more work for you...).
It might be better to isolate all the factor stuff in this class, and force the derived class to take it into account, as opposed to hoping that they will do it. I think we could have therefore something like this
BinNormalisationWithCalibration : BinNormalisation // assuming this is already derived from ParsingObject
{
protected:
get_calib_decay_whatever_factor(const Bin&) const; // TODO find a better name
// needs to be implemented by derived class
float get_uncalibrated_bin_efficiency(const Bin&) = 0;
float get_bin_efficiency(const Bin&)
{ return this->get_uncalibrated_bin_efficiency(bin)/get_calib_decay_whatever_factor(bin); }
void set_calibration_factor(float);
private:
// provide facility to switch off things?
// would need to be added to the parsing keywords
bool use_calibration_factor; // default to true
bool use_branching_ratio; // default to true
};
BinNormalisationFromECAT8 :
public RegisteredParsingObject<BinNormalisationFromECAT8, BinNormalisation, BinNormalisationWithCalibration>
{
// adjust base_type, check that all functions like set_up/set_defaults etc call their base_type version
// during parsing, call `set_calibration_factor()`
// rename get_bin_efficiency to get_uncalibrated_bin_efficiency
// no other changes required
};
In this approach, BinNormalisationWithCalibration
is not a leaf-class, so wouldn't have its own add_start/stop_parsing_key
(as I commented).
hmmm.... What do you think?
Hi, I will take some time to read this carefully, in the meantime I will make step by step the modification you suggested |
I run this with experimental on but I don't get an error with the new code |
I think it is derived from ParsingObject trough registeredObjected (which is derived from RegisterObjectBase, which is derived from ParsingObject). |
ok |
1) create operator == and check function for ExamInfo 2) make start_time and end_time conts float 3) apply changes in parsing.
In ExamInfo or BinNormalisationWithCalibration |
@KrisThielemans Did you submit changes or comments here? I remember you were writing but I don't see them. Anyway I seem to have forgotten to take a note on this but I think I am correct when saying that all get_bin_efficiency() functions will now become get_uncalibrated_bin_efficiency()? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to press the "submit" button...
One problem with this PR is that we're going to break SIRF, as it's using the "old" style apply
(e.g. here) and set_up
(here). Can you keep the old functions in place(only in BinNormalisation
) for backwards compatibility? Flag them as \deprecated
in their doxygen)
src/include/stir/recon_buildblock/BinNormalisationWithCalibration.h
Outdated
Show resolved
Hide resolved
src/include/stir/recon_buildblock/BinNormalisationWithCalibration.h
Outdated
Show resolved
Hide resolved
I remember we said to remove registered_name as we don't use parsing, however I get this error: /home/nmdicom-recon/CalibNorm/STIR/src/include/stir/RegisteredParsingObject.inl:34: error: ‘registered_name’ is not a member of ‘stir::BinNormalisationWithCalibration’{ return Derived::registered_name; } I think this happens when I say: public RegisteredParsingObject<BinNormalisationFromECAT8, BinNormalisation, BinNormalisationWithCalibration> |
src/include/stir/recon_buildblock/BinNormalisationWithCalibration.h
Outdated
Show resolved
Hide resolved
Shall we have two functions for set_up() and apply() or shall we make the new one a property of the derived classes? |
…ionWithCalibration
…libration; change all get__bin_efficiency() with get_uncalibrated_bin_efficiency().
ah, ok. I didn't think you'd do the ECAT7 etc code now (as ideally we'd then read the calibration factor etc from the header), but fine. I'm not sure what to do with the |
The restarted Travis jobs are still timing-out. Did you run the |
src/include/stir/recon_buildblock/BinNormalisationWithCalibration.h
Outdated
Show resolved
Hide resolved
Co-authored-by: Kris Thielemans <[email protected]>
Co-authored-by: Kris Thielemans <[email protected]>
I've cancelled most Travis and Appveyor jobs, to counter global warming... |
travis says that |
let me have a look |
This is the problem: ERROR: BinNormalisation set-up with different ExamInfo. interesting something wrong with the operator == |
I guess should let it print |
They appear to be the same 👍 Called with |
seems the same for ECAT7:
setting it to 1 |
…ibration_factor is set in the parameterfile the calibration factor is overwritten
is this going to release 4.1? |
No. As it brings backwards compatibility on the code level |
I am thinking that BinNormFromProjData also may need to be derived from BinNormWitCalib or else in case like the Mediso scanner where the normalisation comes from projData the factor will not be applied. I do not see any drawback of doing this but maybe I am wrong. |
OK. shall we add something in the userguide? I think we said that this should go togheter with the normalisation section. |
We do need to add something, but I'm not 100% sure where. We probably need a new section on image units, which right now is going to be a bit sketchy.
|
I'm a bit reluctant to do that as it is also used by many to store ACFs. some remarks:
I don't think I'd do this in this PR therefore (or at all). Any reason you cannot create a |
OK, no I suppose I could create a BinNormalisationFromMediso |
So, shall we do it in another PR? |
fine for me. Do you have something in the release notes now? Probably important for people to know this has happened. (could even say in the release notes that documentation is pending, and we edit that in the next PR). |
I was thinking to add it but not sure in which version, 5.0? |
yes please |
I think this is ready to go |
Co-authored-by: Kris Thielemans <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool