27 #include <boost/lexical_cast.hpp>
35 int main(
int argc,
char* argv[])
39 parser.
setCategory(
"Fiber Tracking and Processing Methods");
42 " Simulate a diffusion-weighted image from a tractogram using the specified parameter file.");
45 "output root",
us::Any(),
false);
47 "fiberfox parameter file (.ffp)",
us::Any(),
false);
49 "Input tractogram or diffusion-weighted image.",
us::Any(),
false);
51 "output volume fraction images etc.",
us::Any());
53 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
54 if (parsedArgs.size()==0)
58 string outName =
us::any_cast<
string>(parsedArgs[
"out"]);
59 string paramName =
us::any_cast<
string>(parsedArgs[
"parameters"]);
62 if (parsedArgs.count(
"input"))
67 if (parsedArgs.count(
"verbose"))
75 if( itksys::SystemTools::FileIsDirectory( outName ) )
77 while( *(--(outName.cend())) ==
'/')
81 outName = outName +
'/';
88 while( *(--(outName.cend())) ==
'/')
94 if( ! itksys::SystemTools::GetFilenamePath( outName ).empty()
95 && itksys::SystemTools::FileIsDirectory(itksys::SystemTools::GetFilenamePath( outName ) ) )
97 parameters.
m_Misc.
m_OutputPath = itksys::SystemTools::GetFilenamePath( outName ) +
'/';
104 if( ! itksys::SystemTools::GetFilenameName( outName ).empty() )
117 std::string NameTest = outName;
119 while( itksys::SystemTools::FileExists( outName +
".log" )
122 outName = NameTest +
"_" + boost::lexical_cast<std::string>(c);
136 if ( dynamic_cast<mitk::FiberBundle*>(inputData.GetPointer()) )
138 tractsToDwiFilter->SetFiberBundle(dynamic_cast<mitk::FiberBundle*>(inputData.GetPointer()));
140 else if ( dynamic_cast<mitk::Image*>(inputData.GetPointer()) )
142 typedef itk::VectorImage< short, 3 > ItkDwiType;
157 ->GetGradientDirectionsContainer() );
159 tractsToDwiFilter->SetInputImage(itkVectorImagePointer);
161 tractsToDwiFilter->SetParameters(parameters);
162 tractsToDwiFilter->Update();
177 for (
unsigned int k=0; k<volumeFractions.size(); k++)
180 image->InitializeByItk(volumeFractions.at(k).GetPointer());
181 image->SetVolume(volumeFractions.at(k)->GetBufferPointer());
182 mitk::IOUtil::Save(image, outName+
"_Compartment"+boost::lexical_cast<string>(k)+
".nrrd");
185 if (tractsToDwiFilter->GetPhaseImage().IsNotNull())
193 if (tractsToDwiFilter->GetKspaceImage().IsNotNull())
MiscFiberfoxParameters m_Misc
GUI realted and I/O parameters.
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
static const std::string REFERENCEBVALUEPROPERTYNAME
itk::SmartPointer< Self > Pointer
itk::Point< double, 3 > m_ImageOrigin
Image origin.
Generates artificial diffusion weighted image volume from the input fiberbundle using a generic multi...
static std::string GetTempPath()
itk::Matrix< double, 3, 3 > m_ImageDirection
Image rotation matrix.
void SetGradienDirections(GradientListType gradientList)
void setContributor(std::string contributor)
void SaveParameters(string filename)
Save image generation parameters to .ffp file.
Helper class for mitk::Images containing diffusion weighted data.
DataCollection - Class to facilitate loading/accessing structured data.
ValueType * any_cast(Any *operand)
double m_Bvalue
Acquisition b-value.
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
itk::Vector< double, 3 > m_ImageSpacing
Image voxel size.
double m_SignalScale
Scaling factor for output signal (before noise is added).
Image::Pointer GrabItkImageMemory(itk::SmartPointer< ItkOutputImageType > &itkimage, mitk::Image *mitkImage=nullptr, const BaseGeometry *geometry=nullptr, bool update=true)
Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory.
SignalGenerationParameters m_SignalGen
Signal generation parameters.
void InitializeImage()
Make certain the owned image is up to date with all necessary properties.
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false)
GradientListType GetGradientDirections()
Return gradient direction container.
Image class for storing images.
itk::ImageRegion< 3 > m_ImageRegion
Image size.
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
string m_OutputPath
Image is automatically saved to the specified folder after simulation is finished.
void LoadParameters(string filename)
Load image generation parameters from .ffp file.
static DataStorage::SetOfObjects::Pointer Load(const std::string &path, DataStorage &storage)
Load a file into the given DataStorage.
static const std::string GRADIENTCONTAINERPROPERTYNAME
void setTitle(std::string title)
int main(int argc, char *argv[])
Command line interface to Fiberfox. Simulate a diffusion-weighted image from a tractogram using the s...
void setDescription(std::string description)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.