-
Notifications
You must be signed in to change notification settings - Fork 98
ml_norm for virtual crystals #833
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5c2dc09
Hi
gefeichen 0d9f5d4
ml_norm part with new code
gefeichen 78d00e4
ml_norm part with new code
gefeichen 77dc260
ml_norm part with new code
gefeichen be2608f
ml_norm part with new code
gefeichen 242f472
Merge remote-tracking branch 'origin/test' into test
gefeichen 4c704bb
ml_norm part with new code
gefeichen 55397a8
Merge branch 'master' into test
KrisThielemans 75137ae
minor update to release notes
KrisThielemans cb7f82b
Merge branch 'master' into test
KrisThielemans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
| \author Kris Thielemans | ||
| \author Tahereh Niknejad | ||
| \author Gefei Chen | ||
|
|
||
| */ | ||
|
|
||
|
|
@@ -971,46 +972,6 @@ get_fan_info(int& num_rings, int& num_detectors_per_ring, | |
|
|
||
| } | ||
|
|
||
| void make_fan_data(FanProjData& fan_data, | ||
| const ProjData& proj_data) | ||
| { | ||
| int num_rings; | ||
| int num_detectors_per_ring; | ||
| int fan_size; | ||
| int max_delta; | ||
| shared_ptr<const ProjDataInfoCylindricalNoArcCorr> proj_data_info_ptr = | ||
| get_fan_info(num_rings, num_detectors_per_ring, max_delta, fan_size, | ||
| *proj_data.get_proj_data_info_sptr()); | ||
|
|
||
| const int half_fan_size = fan_size/2; | ||
| fan_data = FanProjData(num_rings, num_detectors_per_ring, max_delta, 2*half_fan_size+1); | ||
|
|
||
| shared_ptr<SegmentBySinogram<float> > segment_ptr; | ||
| Bin bin; | ||
|
|
||
| for (bin.segment_num() = proj_data.get_min_segment_num(); bin.segment_num() <= proj_data.get_max_segment_num(); ++ bin.segment_num()) | ||
| { | ||
| segment_ptr.reset(new SegmentBySinogram<float>(proj_data.get_segment_by_sinogram(bin.segment_num()))); | ||
|
|
||
| for (bin.axial_pos_num() = proj_data.get_min_axial_pos_num(bin.segment_num()); | ||
| bin.axial_pos_num() <= proj_data.get_max_axial_pos_num(bin.segment_num()); | ||
| ++bin.axial_pos_num()) | ||
| for (bin.view_num() = 0; bin.view_num() < num_detectors_per_ring/2; bin.view_num()++) | ||
| for (bin.tangential_pos_num() = -half_fan_size; | ||
| bin.tangential_pos_num() <= half_fan_size; | ||
| ++bin.tangential_pos_num()) | ||
| { | ||
| int ra = 0, a = 0; | ||
| int rb = 0, b = 0; | ||
|
|
||
| proj_data_info_ptr->get_det_pair_for_bin(a, ra, b, rb, bin); | ||
|
|
||
| fan_data(ra, a, rb, b) = | ||
| fan_data(rb, b, ra, a) = | ||
| (*segment_ptr)[bin.axial_pos_num()][bin.view_num()][bin.tangential_pos_num()]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// **** This function make fan_data from projecion file while removing the intermodule gaps **** //// | ||
| /// *** fan_data doesn't have gaps, proj_data has gaps *** /// | ||
|
|
@@ -1027,45 +988,54 @@ void make_fan_data_remove_gaps(FanProjData& fan_data, | |
|
|
||
| const int half_fan_size = fan_size/2; | ||
|
|
||
|
|
||
| // **** Added by me **** // | ||
|
|
||
|
|
||
| const int num_transaxial_blocks = | ||
| proj_data_info_ptr ->get_scanner_sptr()-> | ||
| get_num_transaxial_blocks(); | ||
| const int num_axial_blocks = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_axial_blocks(); | ||
| const int num_transaxial_crystals_per_block = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_transaxial_crystals_per_block(); | ||
| const int num_axial_crystals_per_block = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_axial_crystals_per_block(); | ||
|
|
||
|
|
||
|
|
||
| const int num_transaxial_blocks_in_fansize = fan_size/num_transaxial_crystals_per_block; | ||
| const int new_fan_size = fan_size - num_transaxial_blocks_in_fansize; | ||
| const int virtual_axial_crystals = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_virtual_axial_crystals_per_block(); | ||
|
|
||
| const int virtual_transaxial_crystals = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_virtual_transaxial_crystals_per_block(); | ||
|
|
||
| const int num_transaxial_blocks = | ||
| proj_data_info_ptr ->get_scanner_sptr()-> | ||
| get_num_transaxial_blocks(); | ||
| const int num_axial_blocks = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_axial_blocks(); | ||
| const int num_transaxial_crystals_per_block = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_transaxial_crystals_per_block(); | ||
| const int num_axial_crystals_per_block = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_axial_crystals_per_block(); | ||
|
|
||
| const int num_physical_transaxial_crystals_per_block = num_transaxial_crystals_per_block - virtual_transaxial_crystals; | ||
|
|
||
| const int num_physical_axial_crystals_per_block = num_axial_crystals_per_block - virtual_axial_crystals; | ||
|
|
||
|
|
||
| const int num_transaxial_blocks_in_fansize = fan_size/(num_transaxial_crystals_per_block); | ||
| const int new_fan_size = fan_size - num_transaxial_blocks_in_fansize*virtual_transaxial_crystals; | ||
| const int new_half_fan_size = new_fan_size/2; | ||
| const int num_axial_blocks_in_max_delta = max_delta/num_axial_crystals_per_block; | ||
| const int new_max_delta = max_delta - num_axial_blocks_in_max_delta - 1; | ||
| const int new_num_detectors_per_ring = num_detectors_per_ring - num_transaxial_blocks; | ||
| const int new_num_rings = num_rings - num_axial_blocks; | ||
|
|
||
| const int num_axial_blocks_in_max_delta = max_delta/(num_axial_crystals_per_block); | ||
| const int new_max_delta = max_delta - (num_axial_blocks_in_max_delta)*virtual_axial_crystals; | ||
| const int num_physical_detectors_per_ring = num_detectors_per_ring - num_transaxial_blocks*virtual_transaxial_crystals; | ||
| const int num_physical_rings = num_rings - (num_axial_blocks-1)*virtual_axial_crystals; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with this. |
||
|
|
||
|
|
||
| // **** End **** // | ||
|
|
||
| fan_data = FanProjData(new_num_rings, new_num_detectors_per_ring, new_max_delta, 2*new_half_fan_size+1); | ||
| fan_data = FanProjData(num_physical_rings, num_physical_detectors_per_ring, new_max_delta, 2*new_half_fan_size+1); | ||
|
|
||
|
|
||
|
|
||
| shared_ptr<SegmentBySinogram<float> > segment_ptr; | ||
| Bin bin; | ||
|
|
||
| for (bin.segment_num() = proj_data.get_min_segment_num(); bin.segment_num() <= proj_data.get_max_segment_num(); ++ bin.segment_num()) | ||
| { | ||
| segment_ptr.reset(new SegmentBySinogram<float>(proj_data.get_segment_by_sinogram(bin.segment_num()))); | ||
|
|
||
| for (bin.axial_pos_num() = proj_data.get_min_axial_pos_num(bin.segment_num()); | ||
| bin.axial_pos_num() <= proj_data.get_max_axial_pos_num(bin.segment_num()); | ||
| ++bin.axial_pos_num()) | ||
|
|
@@ -1076,15 +1046,28 @@ void make_fan_data_remove_gaps(FanProjData& fan_data, | |
| { | ||
| int ra = 0, a = 0; | ||
| int rb = 0, b = 0; | ||
|
|
||
| proj_data_info_ptr->get_det_pair_for_bin(a, ra, b, rb, bin); | ||
| int new_a = a - a/num_transaxial_crystals_per_block; | ||
| int new_b = b - b/num_transaxial_crystals_per_block; | ||
| int new_ra = ra - ra/ num_axial_crystals_per_block; | ||
| int new_rb = rb - rb/num_axial_crystals_per_block; | ||
|
|
||
| if ((ra == num_rings -1) || (rb == num_rings -1) || (a == num_detectors_per_ring-1) || (b == num_detectors_per_ring-1)) continue; | ||
|
|
||
| int a_in_block = a % num_transaxial_crystals_per_block; | ||
|
|
||
| if (a_in_block >= num_physical_transaxial_crystals_per_block) | ||
| continue; | ||
| int new_a = a - a / num_transaxial_crystals_per_block; | ||
|
|
||
| int ra_in_block = ra % num_axial_crystals_per_block; | ||
| if (ra_in_block >= num_physical_axial_crystals_per_block) | ||
| continue; | ||
| int new_ra = ra - ra / num_axial_crystals_per_block; | ||
|
|
||
| int b_in_block = b % num_transaxial_crystals_per_block; | ||
| if (b_in_block >= num_physical_transaxial_crystals_per_block) | ||
| continue; | ||
| int new_b = b - b / num_transaxial_crystals_per_block; | ||
|
|
||
| int rb_in_block = rb % num_axial_crystals_per_block; | ||
| if (rb_in_block >= num_physical_axial_crystals_per_block) | ||
| continue; | ||
| int new_rb = rb - rb / num_axial_crystals_per_block; | ||
|
|
||
| fan_data(new_ra, new_a, new_rb, new_b) = | ||
| fan_data(new_rb, new_b, new_ra, new_a) = | ||
|
|
@@ -1094,52 +1077,10 @@ void make_fan_data_remove_gaps(FanProjData& fan_data, | |
| } | ||
|
|
||
|
|
||
| void set_fan_data(ProjData& proj_data, | ||
| const FanProjData& fan_data) | ||
| { | ||
| int num_rings; | ||
| int num_detectors_per_ring; | ||
| int fan_size; | ||
| int max_delta; | ||
| shared_ptr<const ProjDataInfoCylindricalNoArcCorr> proj_data_info_ptr = | ||
| get_fan_info(num_rings, num_detectors_per_ring, max_delta, fan_size, | ||
| *proj_data.get_proj_data_info_sptr()); | ||
|
|
||
| const int half_fan_size = fan_size/2; | ||
| assert(num_rings == fan_data.get_num_rings()); | ||
| assert(num_detectors_per_ring == fan_data.get_num_detectors_per_ring()); | ||
|
|
||
| Bin bin; | ||
| shared_ptr<SegmentBySinogram<float> > segment_ptr; | ||
|
|
||
| for (bin.segment_num() = proj_data.get_min_segment_num(); bin.segment_num() <= proj_data.get_max_segment_num(); ++ bin.segment_num()) | ||
| { | ||
| segment_ptr.reset(new SegmentBySinogram<float>(proj_data.get_empty_segment_by_sinogram(bin.segment_num()))); | ||
|
|
||
| for (bin.axial_pos_num() = proj_data.get_min_axial_pos_num(bin.segment_num()); | ||
| bin.axial_pos_num() <= proj_data.get_max_axial_pos_num(bin.segment_num()); | ||
| ++bin.axial_pos_num()) | ||
| for (bin.view_num() = 0; bin.view_num() < num_detectors_per_ring/2; bin.view_num()++) | ||
| for (bin.tangential_pos_num() = -half_fan_size; | ||
| bin.tangential_pos_num() <= half_fan_size; | ||
| ++bin.tangential_pos_num()) | ||
| { | ||
| int ra = 0, a = 0; | ||
| int rb = 0, b = 0; | ||
|
|
||
| proj_data_info_ptr->get_det_pair_for_bin(a, ra, b, rb, bin); | ||
|
|
||
| (*segment_ptr)[bin.axial_pos_num()][bin.view_num()][bin.tangential_pos_num()] = | ||
| fan_data(ra, a, rb, b); | ||
| } | ||
| proj_data.set_segment(*segment_ptr); | ||
| } | ||
| } | ||
|
|
||
| /// **** This function make proj_data from fan_data while adding the intermodule gaps **** //// | ||
| /// *** fan_data doesn't have gaps, proj_data has gaps *** /// | ||
| void set_fan_data_add_gaps(ProjData& proj_data, | ||
| const FanProjData& fan_data) | ||
| const FanProjData& fan_data, const float gap_value) | ||
| { | ||
| int num_rings; | ||
| int num_detectors_per_ring; | ||
|
|
@@ -1148,37 +1089,40 @@ void set_fan_data_add_gaps(ProjData& proj_data, | |
| shared_ptr<const ProjDataInfoCylindricalNoArcCorr> proj_data_info_ptr = | ||
| get_fan_info(num_rings, num_detectors_per_ring, max_delta, fan_size, | ||
| *proj_data.get_proj_data_info_sptr()); | ||
|
|
||
| const int half_fan_size = fan_size/2; | ||
| //assert(num_rings == fan_data.get_num_rings()); | ||
| //assert(num_detectors_per_ring == fan_data.get_num_detectors_per_ring()); | ||
|
|
||
|
|
||
| // **** Added by Tahereh Nikjenad **** // | ||
|
|
||
| const int virtual_axial_crystals = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_virtual_axial_crystals_per_block(); | ||
| const int virtual_transaxial_crystals = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_virtual_transaxial_crystals_per_block(); | ||
| const int num_transaxial_crystals_per_block = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_transaxial_crystals_per_block(); | ||
| const int num_axial_crystals_per_block = | ||
| proj_data_info_ptr->get_scanner_sptr()-> | ||
| get_num_axial_crystals_per_block(); | ||
|
|
||
| // const int num_axial_detectors = fan_data.get_num_rings(); // Number of ring in fan data (w/o gaps) | ||
| // const int num_transaxial_detectors = fan_data.get_num_detectors_per_ring(); // number of detector per ring in fan data w/o gaps | ||
|
|
||
| // const int num_axial_crystals_per_block = num_axial_detectors/num_axial_blocks; // number of axial detector per block in fan_data w/o gaps | ||
| // const int num_transaxial_crystals_per_block = num_transaxial_detectors/num_transaxial_blocks; // number of transaxial detector per block in fan_data w/o gaps | ||
|
|
||
|
|
||
| const int num_physical_transaxial_crystals_per_block = num_transaxial_crystals_per_block - virtual_transaxial_crystals; | ||
|
|
||
| const int num_physical_axial_crystals_per_block = num_axial_crystals_per_block - virtual_axial_crystals; | ||
|
|
||
|
|
||
| // **** End **** // | ||
|
|
||
| Bin bin; | ||
| shared_ptr<SegmentBySinogram<float> > segment_ptr; | ||
|
|
||
| for (bin.segment_num() = proj_data.get_min_segment_num(); bin.segment_num() <= proj_data.get_max_segment_num(); ++ bin.segment_num()) | ||
| { | ||
| segment_ptr.reset(new SegmentBySinogram<float>(proj_data.get_empty_segment_by_sinogram(bin.segment_num()))); | ||
|
|
||
| for (bin.axial_pos_num() = proj_data.get_min_axial_pos_num(bin.segment_num()); | ||
| bin.axial_pos_num() <= proj_data.get_max_axial_pos_num(bin.segment_num()); | ||
| ++bin.axial_pos_num()) | ||
|
|
@@ -1191,19 +1135,29 @@ void set_fan_data_add_gaps(ProjData& proj_data, | |
| int rb = 0, b = 0; | ||
|
|
||
| proj_data_info_ptr->get_det_pair_for_bin(a, ra, b, rb, bin); | ||
|
|
||
| (*segment_ptr)[bin.axial_pos_num()][bin.view_num()][bin.tangential_pos_num()] = 1e20; | ||
|
|
||
|
|
||
| if ((ra+1)% num_axial_crystals_per_block == 0) continue; | ||
| if ((rb+1)% num_axial_crystals_per_block == 0) continue; | ||
| if ((a+1)% num_transaxial_crystals_per_block == 0) continue; | ||
| if ((b+1)% num_transaxial_crystals_per_block == 0) continue; | ||
|
|
||
| int new_a = a - a/num_transaxial_crystals_per_block; | ||
| int new_b = b - b/num_transaxial_crystals_per_block; | ||
| int new_ra = ra - ra/ num_axial_crystals_per_block; | ||
| int new_rb = rb - rb/num_axial_crystals_per_block; | ||
| (*segment_ptr)[bin.axial_pos_num()][bin.view_num()][bin.tangential_pos_num()] = gap_value; | ||
|
|
||
|
|
||
| int a_in_block = a%num_transaxial_crystals_per_block; | ||
| if(a_in_block>=num_physical_transaxial_crystals_per_block) | ||
| continue; | ||
| int new_a = a-a/num_transaxial_crystals_per_block; | ||
|
|
||
| int ra_in_block = ra%num_axial_crystals_per_block; | ||
| if(ra_in_block>=num_physical_axial_crystals_per_block) | ||
| continue; | ||
| int new_ra = ra-ra/num_axial_crystals_per_block; | ||
|
|
||
| int b_in_block = b%num_transaxial_crystals_per_block; | ||
| if(b_in_block>=num_physical_transaxial_crystals_per_block) | ||
| continue; | ||
| int new_b = b-b/num_transaxial_crystals_per_block; | ||
|
|
||
| int rb_in_block = rb%num_axial_crystals_per_block; | ||
| if(rb_in_block>=num_physical_axial_crystals_per_block) | ||
| continue; | ||
| int new_rb = rb-rb/num_axial_crystals_per_block; | ||
|
|
||
|
|
||
| (*segment_ptr)[bin.axial_pos_num()][bin.view_num()][bin.tangential_pos_num()] = | ||
|
|
@@ -1552,7 +1506,6 @@ void iterate_efficiencies(DetectorEfficiencies& efficiencies, | |
| const FanProjData& model) | ||
| { | ||
| const int num_detectors_per_ring = model.get_num_detectors_per_ring(); | ||
|
|
||
| assert(model.get_min_ra() == data_fan_sums.get_min_index()); | ||
| assert(model.get_max_ra() == data_fan_sums.get_max_index()); | ||
| assert(model.get_min_a() == data_fan_sums[data_fan_sums.get_min_index()].get_min_index()); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I guess we could just as well provide the member functions for these 2 as well.