STIR icon indicating copy to clipboard operation
STIR copied to clipboard

making normalisation and random functionality templated to support B…

Open danieldeidda opened this issue 3 years ago • 6 comments

…lockOnCylindrical

danieldeidda avatar Oct 21 '22 16:10 danieldeidda

sorry it doesn't let me use the botton "add suggestion to batch"

image

KrisThielemans avatar Oct 21 '22 17:10 KrisThielemans

I see a warning on AppVeyor

C:\projects\stir\src\buildblock\multiply_crystal_factors.cxx(95): warning C4067: unexpected tokens following preprocessor directive - expected a newline

This is a mistake of mine I guess https://github.com/UCL/STIR/blob/b480282099055080a3efd11f4fe098f4803ed241/src/buildblock/multiply_crystal_factors.cxx#L95 can you replace and with &&?

KrisThielemans avatar Oct 25 '22 11:10 KrisThielemans

sorry it doesn't let me use the botton "add suggestion to batch"

also not from the Files tab?

KrisThielemans avatar Oct 26 '22 08:10 KrisThielemans

I'd take the opportunity to remove get_fan_info from ML_norm.h and make it a static function. (It's just a convenience function here. shouldn't be used by anybody else).

get_fan_info is called by find_ML_singles... though

danieldeidda avatar Oct 26 '22 10:10 danieldeidda

also if get_fan_info goes back to original we will trigger this:


if (proj_data_info_ptr == 0)
        {
          error("Can only process not arc-corrected data\n");
        }

danieldeidda avatar Oct 26 '22 10:10 danieldeidda

I'd take the opportunity to remove get_fan_info from ML_norm.h and make it a static function. (It's just a convenience function here. shouldn't be used by anybody else).

get_fan_info is called by find_ML_singles... though

ok true. that should be revamped a bit, but I'm not up for that now. However, that doesn't use its return value, so making it a void will still work.

also if get_fan_info goes back to original we will trigger this:


if (proj_data_info_ptr == 0)
        {
          error("Can only process not arc-corrected data\n");
        }

Those conditions should be removed there, and in the other functions, I'd replace

    if (proj_data.get_proj_data_info_sptr()->get_scanner_ptr()->get_scanner_geometry()=="Cylindrical")
    {
        auto proj_data_info_ptr =
                dynamic_cast<const ProjDataInfoCylindricalNoArcCorr * const>(&proj_data_info);

        make_fan_data_remove_gaps_help(fan_data, num_rings, num_detectors_per_ring, max_delta, fan_size, *proj_data_info_ptr, proj_data);
    }
    else
    {
        auto proj_data_info_ptr =
                dynamic_cast<const ProjDataInfoBlocksOnCylindricalNoArcCorr * const>(&proj_data_info);

        make_fan_data_remove_gaps_help(fan_data, num_rings, num_detectors_per_ring, max_delta, fan_size, *proj_data_info_ptr, proj_data);
    }

with

    if (auto proj_data_info_ptr =
                dynamic_cast<const ProjDataInfoCylindricalNoArcCorr * const>(proj_data.get_proj_data_info_sptr()))
   {
        make_fan_data_remove_gaps_help(fan_data, num_rings, num_detectors_per_ring, max_delta, fan_size, *proj_data_info_ptr, proj_data);
    }
    else if (auto proj_data_info_ptr =
                dynamic_cast<const ProjDataInfoBlocksOnCylindricalNoArcCorr * const>(proj_data.get_proj_data_info_sptr()))

        make_fan_data_remove_gaps_help(fan_data, num_rings, num_detectors_per_ring, max_delta, fan_size, *proj_data_info_ptr, proj_data);
    }
   else
  {
     error("ML_norm functions only support non-arccorrected data (cylindrical or blocks-on-cylindrical) at the moment.");
  }

or something like that.

get_fan_info will need to do a dynamic_cast to ProjDataInfoCylindrical at the moment to get at get_max_ring_difference, but that should be it.

...maybe....

KrisThielemans avatar Oct 27 '22 10:10 KrisThielemans

those condition were already removed from get_fan_info but the error is triggered when doing the bit the was originally there:

proj_data_info_ptr =
                dynamic_cast<const ProjDataInfoCylindricalNoArcCorr * const>(&proj_data_info);

        if (proj_data_info_ptr == 0)
        {
          error("Can only process not arc-corrected data\n");
        }

are you saying we can remove this check?

danieldeidda avatar Oct 28 '22 16:10 danieldeidda

yes, we need to check on ProjDataInfoCylnidrical, not more

KrisThielemans avatar Oct 28 '22 16:10 KrisThielemans

Add a test case to test_ML_norm.cxx. should be trivial

you mean the same as test_proj_data_info(shared_ptr<const ProjDataInfoCylindricalNoArcCorr> proj_data_info_sptr)

but for blocksOnCylindrical?

danieldeidda avatar Oct 28 '22 17:10 danieldeidda

yes.

KrisThielemans avatar Oct 28 '22 17:10 KrisThielemans

This is now fine. I've cleaned-up the history a bit, and undid white-space changes in apply_normfactors.cxx. I'm afraid I force pushed to your branch. sorry. That was a bad idea!

KrisThielemans avatar Nov 16 '22 15:11 KrisThielemans

I'll merge soon after it got through the GHA tests (won't wait for Appveyor)

KrisThielemans avatar Nov 16 '22 15:11 KrisThielemans

@emikhay @markus-jehl we believe this should allow randoms and norm without having to switch to cylindrical. Let us know if not.

KrisThielemans avatar Nov 16 '22 17:11 KrisThielemans

This works, thank you!

markus-jehl avatar Nov 16 '22 17:11 markus-jehl