Skip to content

Commit

Permalink
Adds output to SimulateStacksCardiac
Browse files Browse the repository at this point in the history
- saves transformations
- calculates displacements
- saves info
  • Loading branch information
Joshua van Amerom committed Nov 15, 2017
1 parent f03ff27 commit a1eb1d7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/segmentation/applications/reconstructionCardiac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int main(int argc, char **argv)

irtkRealImage average;

string info_filename = "slice_info.tsv";
string info_filename = "info.tsv";
string log_id;
bool no_log = false;

Expand Down Expand Up @@ -1308,7 +1308,7 @@ int main(int argc, char **argv)
if(debug)
{
cout<<"SlicesInfoCardiac4D"<<endl;
sprintf(buffer,"slice_info_mc%02i.tsv",iter);
sprintf(buffer,"info_mc%02i.tsv",iter);
reconstruction.SlicesInfoCardiac4D( buffer, stack_files );
}

Expand Down
21 changes: 21 additions & 0 deletions packages/segmentation/applications/simulateStacksCardiac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ int main(int argc, char **argv)
reconstruction.SetReconstructedCardiacPhase( reconstructedCardPhase );
reconstruction.SetReconstructedTemporalResolution( rrInterval/numCardPhase );

//initialise stack factors
reconstruction.InitStackFactor(stacks);

//type of recon - default 3D PSF
if(recon_1d) {
cout<<"Set1DRecon()" << endl;
Expand Down Expand Up @@ -580,6 +583,24 @@ int main(int argc, char **argv)
}
}

//Calculate displacements
double mean_displacement = reconstruction.CalculateDisplacement();
if (debug)
cout<<"\tmean displacement = "<<mean_displacement<<" mm."<<endl;
double mean__weighted_displacement = reconstruction.CalculateWeightedDisplacement();
if (debug)
cout<<"\tmean weighted displacement = "<<mean__weighted_displacement<<" mm."<<endl;

//Save info
if (debug)
cout<<"Saving Info"<<endl;
reconstruction.SlicesInfoCardiac4D( "info.tsv", stack_files );

//Save transformations
if(debug)
cout<<"SaveTransformations"<<endl;
reconstruction.SaveTransformations();

//Save cine volume
if(debug)
cout<<"Saving cine volume."<<endl;
Expand Down
3 changes: 3 additions & 0 deletions packages/segmentation/include/irtkReconstructionCardiac4D.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ class irtkReconstructionCardiac4D : public irtkReconstruction
double averageValue,
bool together=false);

//Set stack factors
void InitStackFactor(vector<irtkRealImage>& stacks);

// Create slices from the stacks and
// slice-dependent transformations from stack transformations
void CreateSlicesAndTransformationsCardiac4D( vector<irtkRealImage>& stacks,
Expand Down
17 changes: 17 additions & 0 deletions packages/segmentation/src/irtkReconstructionCardiac4D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,16 @@ void irtkReconstructionCardiac4D::MatchStackIntensitiesWithMasking(vector<irtkRe

}

// -----------------------------------------------------------------------------
// Initialise Stack Factor
// -----------------------------------------------------------------------------
void irtkReconstructionCardiac4D::InitStackFactor(vector<irtkRealImage> &stacks)
{
_stack_factor.clear();
for(unsigned int stackIndex=0; stackIndex<stacks.size(); stackIndex++)
_stack_factor.push_back(1);
}


// -----------------------------------------------------------------------------
// Create Slices and Associated Transformations
Expand Down Expand Up @@ -409,6 +419,8 @@ void irtkReconstructionCardiac4D::CreateSlicesAndTransformationsCardiac4D( vecto
proba.PutPixelSize(attr._dx, attr._dy, thickness[i], attr._dt);
_probability_maps.push_back(proba);
}
//initialise cardiac phase to use for 2D-3D registration
_slice_svr_card_index.push_back(0);
}
loc_index++;
}
Expand Down Expand Up @@ -1631,6 +1643,11 @@ void irtkReconstructionCardiac4D::SimulateStacksCardiac4D(vector<bool> stack_exc
//Initialise simlated images
for (unsigned int inputIndex = 0; inputIndex < _slices.size(); ++inputIndex) _simulated_slices[inputIndex] = 0;

//Initialise indicator of images having overlap with volume
_slice_inside.clear();
for (unsigned int inputIndex = 0; inputIndex < _slices.size(); ++inputIndex)
_slice_inside.push_back(true);

//Simulate images
cout << "Simulating...";
cout.flush();
Expand Down

0 comments on commit a1eb1d7

Please sign in to comment.