Skip to content

Implementation of normalization at tiff2dose stage#57

Merged
petruong merged 25 commits intoOMG_masterfrom
CISSSO_Integration
Jul 10, 2025
Merged

Implementation of normalization at tiff2dose stage#57
petruong merged 25 commits intoOMG_masterfrom
CISSSO_Integration

Conversation

@petruong
Copy link
Collaborator

@petruong petruong commented Jul 8, 2025

Analysis.py

  • Removed "centering" of coordinates.
  • Retain x and y coordinates to start from 0 as these are the same coordinates for the analysis portion of the film and reference dose array maps.
  • Renamed qa_patients\CISSSO version of the dose2analysis script.
  • JFC: Fixed a bug in apply_factor_from_norm_film method
  • JFC: Changed keyboard actions in select_markers() :
    • 'r' = rotate
    • 'h' = flip horizontally (PT: updated to 'l' keypress. Review note further down)
    • 'v' = flip vertically
    • numpad arrows = move last placed marker
  • JFC: Simplification of registration functions/Code simplification and optimization
  • JFC: Improved docstrings
  • To better review the endpoint for the variable dose/distance gamma criteria, the endpoint dose/distance parameter is included in the plot_gamma_var... functions for both dose and distance.
  • This parameter by default is None, which will take it from the self value per normal.
  • Included the endpoint to be analyzed/visualized in the range.
  • In show_results() function, the first four axes (film dose, ref dose, gamma, RMSE) have been assigned to share the same x and y properties. This allows the zoom function to zoom for all 4 axes at the same time showing the same location.
  • Changed ontype 'key" event from 'h' to 'l' since in a matplot figure instance/window, 'h' is a shortcut (home) to reset the view.
    • To be honest, tested in 'l' in analysis.show_results and it seemed buggy. Obviously, it's meant to be applied in select_markers function, but other key_press_events might still be carried over across other matplot figure instances.
  • In the case where film_dose_factor is no longer determined in the DoseAnalysis stage (i.e., performed in tiff2dose), then to have the correct film_dose_factor displayed in the pdfs and figures, the film_dose_factor parameter can be used with the factor calculated from tiff2dose; however, in order to prevent having factors applied twice, added the parameter apply_dose_factors, which is default at True considering that film_dose_factor and ref_dose_factor are default at 1.
  • DoseAnalysis object to initialize this property outside of the apply_film_factor and apply_ref_factor function.

tiff2dose.py

  • In show_results() function, all axes have been assigned to share the same x and y properties. This allows the zoom function to zoom for all axes at the same time showing the same location.
  • Incorporation of flipLR and flipUD parameters (similar to DoseAnalysis module) allowing for the orientation/view of the dose image to already match reference dose orientation/view. Having this step performed at tiff2dose step voids the need to have it done at the DoseAnalysis stage.
  • Created function normalize_dose_opt to start off process with assigning a separate norm film dose map if normalization film was scanned separately or not from the QA film. If it was scanned at the same time, then it will default to the film dose array to select the ROI.
  • Modified the apply_factor_from_roi, apply_factor_from_roi_press_enter, and apply_film_factor functions from DoseAnalysis module to only adjust the tiff2dose.Gaf.dose_opt array as this is what is primarily saved and used afterwards in the DoseAnalysis stage.

OMG_CISSSO_Test.py (renamed to OMG_CISSSO.py)

  • Inclusion for clarification of normalization reference setup.
  • CISSSO changes in separate branch in order to avoid conflicts in branches worked on by other people.
  • Correction for renaming OMG_CISSSO_Test script as its old named was retained.
    • Changes applied were moving normFilm_selection declaration from line 56 to 65.
    • Added some comments
  • Update organization for normalization/reference film parameters.
  • Adjusted/updated a few comments
  • Update LUT file path references for CISSSO usage.
  • Due to changes in timing for flipLR and flipUD being called at the tiff2dose stage, removed parameters used for the DoseAnalysis call.
  • Removed redundant variable rot_scan which was essentially used in the same way as rot90 when utilized in DoseAnalysis.
  • Adjusted the order in steps for how it is called/utilized in CISSSO test patient QA workflow now that normalization is applied prior to the DoseAnalysis step.
  • Reorganized a bit the tiff2dose section as this was an optional "creation" of tiff2dose objects/images; however, in future commits, this may be taken out completely, because in order for the analysis to work, it always has to have some instance of a tiff2dose ran/created.
  • Removed redundant parameters in local function gamma_analysis as they're locally initialized in this script anyways (description to better clarify the situation).

Commentary: CISSSO branch merged updates from dev_analysis branch (contents not yet uploaded/merged with master branch) hence the major modifications included in this pull request. Bulk of the modifications are for analysis.py based on the cleanup/optimization from JFC side, but the goal of this pull request was for the implementation of the normalization steps at the tiff2dose stage (involved manipulation of image array and calculation/application of normalization factor) based on the discussions made here: #56.
Other major functionality changes is to the analysis.py function for varied gamma or distance parameters in the gamma analysis (plot_gamma_var, plot_dist_var) along with shared coordinates in the analysis.py/tiff2dose.py in the show_results function (zoom/change of view will match across all subplots).

petruong and others added 24 commits February 20, 2024 13:49
- Removed "centering" of coordinates.
- Retain x and y coordinates to start from 0 as these are the same coordinates for the analysis portion of the film and reference dose array maps.

- Renamed qa_patients\CISSSO version of the dose2analysis script.
Fixed a bug in apply_factor_from_norm_film method
Changed keyboard actions in select_markers() :
- 'r' = rotate
- 'h' = flip horizontally
- 'v' = flip vertically
- numpad arrows = move last placed marker
Simplification of registration functions
Code simplification and optimization
Simplification et optimisation
Improved docstrings
tiff2dose.py
- In show_results() function, all axes have been assigned to share the same x and y properties. This allows the zoom function to zoom for all axes at the same time showing the same location.

OMG_CISSSO_Test.py
- Inclusion for clarification of normalization reference setup.
analysis.py
- To better review the endpoint for the variable dose/distance gamma criteria, the endpoint dose/distance parameter is included in the plot_gamma_var... functions for both dose and distance.
- This parameter by default is None, which will take it from the self value per normal.
- Included the endpoint to be analyzed/visualized in the range.
- In show_results() function, the first four axes (film dose, ref dose, gamma, RMSE) have been assigned to share the same x and y properties. This allows the zoom function to zoom for all 4 axes at the same time showing the same location.
- Changed ontype 'key" event from 'h' to 'l' since in a matplot figure instance/window, 'h' is a shortcut (home) to reset the view.
 - To be honest, tested in 'l' in analysis.show_results and it seemed buggy. Obviously, it's meant to be applied in select_markers function, but other key_press_events might still be carried over across other matplot figure instances.
- CISSSO changes in separate branch in order to avoid conflicts in branches worked on by other people.

- Correction for renaming OMG_CISSSO_Test script as its old named was retained.
 - Changes applied were moving normFilm_selection declaration from line 56 to 65.
 - Added some comments
- Update organization for normalization/reference film parameters.
- Adjusted/updated a few comments
Update LUT file path references for CISSSO usage.
tiff2dose.py
- Incorporation of flipLR and flipUD parameters (similar to DoseAnalysis module) allowing for the orientation/view of the dose image to already match reference dose orientation/view. Having this step performed at tiff2dose step voids the need to have it done at the DoseAnalysis stage.

OMG_CISSSO_Test.py
- Due to changes in timing for flipLR and flipUD being called at the tiff2dose stage, removed parameters used for the DoseAnalysis call.
- Removed redundant variable rot_scan which was essentially used in the same way as rot90 when utilized in DoseAnalysis.
tiff2dose.py
- Created function normalize_dose_opt to start off process with assigning a separate norm film dose map if normalization film was scanned separately or not from the QA film. If it was scanned at the same time, then it will default to the film dose array to select the ROI.
- Modified the apply_factor_from_roi, apply_factor_from_roi_press_enter, and apply_film_factor functions from DoseAnalysis module to only adjust the tiff2dose.Gaf.dose_opt array as this is what is primarily saved and used afterwards in the DoseAnalysis stage.

OMG_CISSSO_Test.py
- Adjusted the order in steps for how it is called/utilized in CISSSO test patient QA workflow now that normalization is applied prior to the DoseAnalysis step.
analysis.py
- In the case where film_dose_factor is no longer determined in the DoseAnalysis stage (i.e., performed in tiff2dose), then to have the correct film_dose_factor displayed in the pdfs and figures, the film_dose_factor parameter can be used with the factor calculated from tiff2dose; however, in order to prevent having factors applied twice, added the parameter apply_dose_factors, which is default at True considering that film_dose_factor and ref_dose_factor are default at 1.
- DoseAnalysis object to initialize this property outside of the apply_film_factor and apply_ref_factor function.

OMG_CISSSO.py (to be renamed).
- Reorganized a bit the tiff2dose section as this was an optional "creation" of tiff2dose objects/images; however, in future commits, this may be taken out completely, because in order for the analysis to work, it always has to have some instance of a tiff2dose ran/created.
- Removed redundant parameters in local function gamma_analysis as they're locally initialized in this script anyways (description to better clarify the situation).
- Renamed OMG_CISSSO_Test.py to OMG_CISSSO.py.
- Updated versioning from 1.7.1 to 1.7.2 to pyprject.toml and docs/source/conf.py.
@petruong petruong requested a review from jfcabana July 8, 2025 14:33
@jfcabana
Copy link
Owner

Haven't try it yet, but it looks ok to me. I forgot I had all theses changes to analysis that were not yet in master :D

@petruong
Copy link
Collaborator Author

@LuisOlivaresJ One question I had was concerning on if my changes to version 1.7.2 are correct to automatically have Github know what the latest version is.
Technically, these are some pretty big changes to the structure of the modules, maybe it is even worth it to have it updated to 1.8.1. Though, 1.8.1 could be reserved for when the two-point factor has been implemented into the normalization.
Thoughts before the merge?

@jfcabana
Copy link
Owner

@LuisOlivaresJ One question I had was concerning on if my changes to version 1.7.2 are correct to automatically have Github know what the latest version is. Technically, these are some pretty big changes to the structure of the modules, maybe it is even worth it to have it updated to 1.8.1. Though, 1.8.1 could be reserved for when the two-point factor has been implemented into the normalization. Thoughts before the merge?

From what I remember reading I think we should change it to 1.8.0. Last digit increment is for bug fixes, second digit would be when new features are implemented, first digit is when changes are not backward compatible.

@petruong
Copy link
Collaborator Author

Versioning updated from 1.7.1 (2) to 1.8.0 in latest commit.

@petruong petruong merged commit c2f6658 into OMG_master Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants