diff --git a/Modules/DiffusionImaging/DiffusionCore/Algorithms/itkProjectionFilter.h b/Modules/DiffusionImaging/DiffusionCore/Algorithms/itkProjectionFilter.h index 163bf99444..501e56c07b 100644 --- a/Modules/DiffusionImaging/DiffusionCore/Algorithms/itkProjectionFilter.h +++ b/Modules/DiffusionImaging/DiffusionCore/Algorithms/itkProjectionFilter.h @@ -1,155 +1,158 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef ITKPROJECTIONFILTER_H_ #define ITKPROJECTIONFILTER_H_ #include "itkObject.h" #include "itkImage.h" #include "mitkImage.h" #include "mitkTbssImage.h" namespace itk { /** * \brief Projection part of the TBSS pipeline * * This class performs the projection step of the TBSS pipeline * (see Smith et al., 2009. http://dx.doi.org/10.1016/j.neuroimage.2006.02.024 ) * As input it takes a binary skeleton, a distance map, and a vector image containing the image gradients * that are typically provided by the itkSkeletonizationFilter and the itkDistanceMapFilter. + * Furthermore it requires a 4d dataset with patient data registered to the same space as the mean FA image. + * This 4D dataset is typically created by the TBSS pipeline (see http://fsl.fmrib.ox.ac.uk/fsl/fsl4.0/tbss/index), + * in which case it is often named all_FA.nii.gz */ class ProjectionFilter : public Object { public: typedef itk::Image RealImageType; typedef itk::CovariantVector VectorType; typedef itk::Image VectorImageType; typedef itk::Image CharImageType; typedef itk::Image Float4DImageType; typedef itk::Image FloatImageType; public: /** */ typedef ProjectionFilter Self; /** Superclass */ typedef Object Superclass; /** Smart Pointer */ typedef SmartPointer Pointer; /** Smart Pointer */ typedef SmartPointer ConstPointer; /** */ itkNewMacro( Self) /** \brief Does the actual projection */ void Project(); /** \brief Set the distance map * * Sets the distance map that decodes for every voxel the distance to the nearest point on the skeleton. */ itkSetMacro(DistanceMap, RealImageType::Pointer) /** \brief Set the directions * * Sets the direction calculated by the TBSS skeletonization algorithm in itkSkeletonizationFilter. */ itkSetMacro(Directions, VectorImageType::Pointer) /** \brief Set the binary skeleton * * Sets the binary skeleton that defines on which voxels must be projected. */ itkSetMacro(Skeleton, CharImageType::Pointer) /** \brief Set the mask defining tubular structures on the skeleton * * Sets a binary mask that defines wich part of the white matter skeleton are tubular instead of sheet like. * This is important because the a different projection method is used for sheet like structues and * tubular structures. */ itkSetMacro(Tube, CharImageType::Pointer) /** \brief Set a 4D image containing the 3D registered FA maps of all study subjects. */ itkSetMacro(AllFA, Float4DImageType::Pointer) /** \brief Returns a 4D image containing the skeleton projections of all subjects */ itkGetMacro(Projections, Float4DImageType::Pointer) protected: /** Constructor */ ProjectionFilter(); /** Destructor */ virtual ~ProjectionFilter(); RealImageType::Pointer m_DistanceMap; VectorImageType::Pointer m_Directions; CharImageType::Pointer m_Skeleton; CharImageType::Pointer m_Tube; Float4DImageType::Pointer m_Projections; Float4DImageType::Pointer m_AllFA; int round(float x) { if (x>0.0) return ((int) (x+0.5)); else return ((int) (x-0.5)); } protected: }; } #ifndef ITK_MANUAL_INSTANTIATION #include "itkProjectionFilter.txx" #endif #endif diff --git a/Modules/DiffusionImaging/Quantification/Algorithms/itkSkeletonizationFilter.h b/Modules/DiffusionImaging/Quantification/Algorithms/itkSkeletonizationFilter.h index 9a46f4f167..9319c4ce8a 100644 --- a/Modules/DiffusionImaging/Quantification/Algorithms/itkSkeletonizationFilter.h +++ b/Modules/DiffusionImaging/Quantification/Algorithms/itkSkeletonizationFilter.h @@ -1,115 +1,118 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef ITKSKELETONIZATIONFILTER_H_ #define ITKSKELETONIZATIONFILTER_H_ #include "itkImageToImageFilter.h" #include "itkImage.h" #include "mitkImage.h" #include namespace itk { /** * \brief Skeletonization part of the TBSS pipeline * - * This class takes a 3D image (typically the mean FA image as calculated in the standard TBSS pipeline) - * and performs the non-maximum-suppression (see Smith et al., 2009. http://dx.doi.org/10.1016/j.neuroimage.2006.02.024 ) + * This class takes a 3D image which is typically the mean FA image that is calculated after registration by the FSL TBSS pipeline (see + * http://fsl.fmrib.ox.ac.uk/fsl/fsl4.0/tbss/index for the user manual) and performs the non-maximum-suppression to create a white matter skeleton. + * + * + * The skeletonization algorithm is described in Smith et al., 2009. http://dx.doi.org/10.1016/j.neuroimage.2006.02.024 ) */ template < class TInputImage, class TOutputImage > class SkeletonizationFilter : public ImageToImageFilter { public: /** Typedef for input ImageType. */ typedef TInputImage InputImageType; typedef itk::CovariantVector VectorType; typedef itk::Image VectorImageType; /** Typedef for output ImageType. */ typedef TOutputImage OutputImageType; typedef itk::VectorImage GradientImageType; /** */ typedef SkeletonizationFilter Self; /** Superclass */ typedef ImageToImageFilter Superclass; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; itkNewMacro( Self) /** \brief Performs the work */ virtual void GenerateData(); /** \brief Output the gradient image as itkVectorImage * * Output the gradient image by first converting it to an itk vector image */ GradientImageType::Pointer GetGradientImage(); /** \brief Output the gradient image as an itkImage containing vector */ VectorImageType::Pointer GetVectorImage() { return m_DirectionImage; } protected: SkeletonizationFilter(); virtual ~SkeletonizationFilter(); VectorImageType::Pointer m_DirectionImage; int round(float x) { if (x>0.0) return ((int) (x+0.5)); else return ((int) (x-0.5)); } protected: }; } #ifndef ITK_MANUAL_INSTANTIATION #include "itkSkeletonizationFilter.txx" #endif #endif diff --git a/Modules/DiffusionImaging/Quantification/Algorithms/mitkTractAnalyzer.h b/Modules/DiffusionImaging/Quantification/Algorithms/mitkTractAnalyzer.h index 0f508ca5a6..4e782fc8b3 100644 --- a/Modules/DiffusionImaging/Quantification/Algorithms/mitkTractAnalyzer.h +++ b/Modules/DiffusionImaging/Quantification/Algorithms/mitkTractAnalyzer.h @@ -1,152 +1,151 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkTractAnalyzer_h_ #define __mitkTractAnalyzer_h_ #include "QuantificationExports.h" #include #include "mitkImage.h" #include "mitkImageCast.h" #include #include namespace mitk{ /** * \brief Creates a region of interest for tract-specific analysis of existing TBSS data * - * This class needs a 3D image (typically a mean FA skeleton as produced by the standard TBSS pipeline of FSL) - * and a user-defined point set defining the points through which the region of interest should pass. + * This class needs a 3D image, which is the mean FA skeleton as produced by the standard TBSS pipeline of FSL. + * How this dataset can be obtained can be found in the TBSS user manual: http://fsl.fmrib.ox.ac.uk/fsl/fsl4.0/tbss/index + * Furthermore, this class requires a user-defined point set defining the points through which the region of interest should pass. + * The output is a TBSS roi image, which is a binary images defining the roi and metadata containing indices + * that can be used for plotting graphs using the QmitkTbssRoiAnalysisWidget */ class Quantification_EXPORT TractAnalyzer { public: TractAnalyzer(); ~TractAnalyzer() {} /** Image type definitions */ typedef itk::Image CharImageType; typedef itk::Image FloatImageType; /** \brief Main method for region of interest calculation * * A region of interest is calculated adding the segments between the points on the ROI * that was specified by the user. */ void MakeRoi(); - /** \brief Sets the input image - * - * The region of interest is calculated on a 3D image. This is generally the mean FA skeleton as calculated - * in the standard TBSS pipeline (see http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TBSS). - */ + /** \brief Returns the TbssRoiImage **/ mitk::TbssRoiImage::Pointer GetRoiImage() { return m_TbssRoi; } /** \brief Sets the input image * * The region of interest is calculated on a 3D image. This is generally the mean FA skeleton as calculated * in the standard TBSS pipeline (see http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TBSS). */ void SetInputImage(mitk::Image::Pointer inputImage) { m_InputImage = inputImage; } /** \brief Sets the user-defined point set * * Set the user-defined point sets. The region of interest must pass through these points. */ void SetPointSet(mitk::PointSet::Pointer pointSet) { m_PointSetNode = pointSet; } /** \brief Sets a lower bound for the threshold. * * Low fractional anisotropy values can indicate partial volume of non white matter tissue. * This thresholds limits the search for a region of interest to voxels with a minimum value. */ void SetThreshold(double threshold) { m_Threshold = threshold; } /** \brief Returns a string with the indices of points on the region of interest * * The region of interest calculated by the TractAnalyzer contains a list of ITK indices. * This method returns a string containing these indices for display in the GUI */ std::string GetPathDescription() { return m_PathDescription; } protected: /** \brief Calculates a segment of the region of interest * * The region of interest is calculated on a 3D image. This is generally the mean FA skeleton as calculated * in the standard TBSS pipeline (see http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TBSS). */ std::vector< itk::Index<3> > CreateSegment(itk::Index<3> startPoint, itk::Index<3> endPoint); /** \brief Output TbssRoiImage */ mitk::TbssRoiImage::Pointer m_TbssRoi; /** \brief Inputimage */ mitk::Image::Pointer m_InputImage; /** \brief Threshold for ROI search */ double m_Threshold; /** \brief User defined point set */ mitk::PointSet::Pointer m_PointSetNode; /** \brief Path description in as string for display in GUI */ std::string m_PathDescription; private: }; } #endif //__itkTractAnalyzer_h_ diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.h index 238bd07a6d..f564c2b535 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.h +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.h @@ -1,226 +1,229 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkTbssRoiAnalysisWidget_H_ #define QmitkTbssRoiAnalysisWidget_H_ #include "QmitkPlotWidget.h" #include #include #include #include typedef itk::VectorImage VectorImageType; typedef std::vector< itk::Index<3> > RoiType; typedef itk::Point PointType; typedef std::vector< PointType> TractType; typedef std::vector< TractType > TractContainerType; class QwtPlotPicker; /** * \brief Plot widget for TBSS Data - * This widget can plot regions of interest on TBSS projection data. + * This widget can plot regions of interest on TBSS projection data. The projection data is created by importing FSL TBSS subject data and + * completing it with patient data using the QmitkTractbasedSpatialStatisticsView. + * The region of interest is a vector of indices from which data for plotting should be obtained. */ + class DIFFUSIONIMAGING_EXPORT QmitkTbssRoiAnalysisWidget : public QmitkPlotWidget { Q_OBJECT public: QmitkTbssRoiAnalysisWidget( QWidget * parent); virtual ~QmitkTbssRoiAnalysisWidget(); - /* \brief Set group information */ + /* \brief Set group information as a vector of pairs of group name and number of group members */ void SetGroups(std::vector< std::pair > groups) { m_Groups = groups; } /* \brief Draws the group averaged profiles */ void DrawProfiles(); void PlotFiber4D(mitk::TbssImage::Pointer tbssImage, mitk::FiberBundleX *fib, mitk::PlanarFigure* startRoi, mitk::PlanarFigure* endRoi, int number); void PlotFiberBundles(TractContainerType tracts, mitk::Image* img, bool avg=false); /* \brief Sets the projections of the individual subjects */ void SetProjections(VectorImageType::Pointer projections) { m_Projections = projections; } /* \brief Set the region of interest*/ void SetRoi(RoiType roi) { m_Roi = roi; } /* \brief Set structure information to display in the plot */ void SetStructure(std::string structure) { m_Structure = structure; } /* \brief Set measurement type for display in the plot */ void SetMeasure(std::string measure) { m_Measure = measure; } /* \brief Draws a bar to indicate were the user clicked in the plot */ void drawBar(int x); /* \brief Returns the values of the group averaged profiles */ std::vector > GetVals() { return m_Vals; } /* \brief Returns the values of the individual subjects profiles */ std::vector > GetIndividualProfiles() { return m_IndividualProfiles; } std::vector GetAverageProfile() { return m_Average; } void SetPlottingFiber(bool b) { m_PlottingFiberBundle = b; } bool IsPlottingFiber() { return m_PlottingFiberBundle; } void PlotFiberBetweenRois(mitk::FiberBundleX *fib, mitk::Image* img, mitk::PlanarFigure* startRoi, mitk::PlanarFigure* endRoi, bool avg=-1, int number=25); // Takes an index which is an x coordinate from the plot and finds the corresponding position in world space mitk::Point3D GetPositionInWorld(int index); void ModifyPlot(int number, bool avg); QwtPlotPicker* m_PlotPicker; protected: mitk::FiberBundleX* m_Fib; std::vector< std::vector > m_Vals; std::vector< std::vector > m_IndividualProfiles; std::vector< double > m_Average; std::vector< std::vector > CalculateGroupProfiles(); std::vector< std::vector > CalculateGroupProfilesFibers(mitk::TbssImage::Pointer tbssImage, mitk::FiberBundleX *fib, mitk::PlanarFigure* startRoi, mitk::PlanarFigure* endRoi, int number); void Plot(std::vector > groupProfiles); void Tokenize(const std::string& str, std::vector& tokens, const std::string& delimiters = " ") { // Skip delimiters at beginning. std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first "non-delimiter". std::string::size_type pos = str.find_first_of(delimiters, lastPos); while (std::string::npos != pos || std::string::npos != lastPos) { // Found a token, add it to the vector. tokens.push_back(str.substr(lastPos, pos - lastPos)); // Skip delimiters. Note the "not_of" lastPos = str.find_first_not_of(delimiters, pos); // Find next "non-delimiter" pos = str.find_first_of(delimiters, lastPos); } } std::vector< std::pair > m_Groups; VectorImageType::Pointer m_Projections; RoiType m_Roi; std::string m_Structure; std::string m_Measure; bool m_PlottingFiberBundle; // true when the plot results from a fiber tracking result (vtk .fib file) // Resample a collection of tracts so that every tract contains #number equidistant samples TractContainerType ParameterizeTracts(TractContainerType tracts, int number); TractContainerType m_CurrentTracts; mitk::Image* m_CurrentImage; mitk::TbssImage* m_CurrentTbssImage; mitk::PlanarFigure* m_CurrentStartRoi; mitk::PlanarFigure* m_CurrentEndRoi; void DoPlotFiberBundles(mitk::FiberBundleX *fib, mitk::Image* img, mitk::PlanarFigure* startRoi, mitk::PlanarFigure* endRoi, bool avg=false, int number=25); /* \brief Creates tracts from a mitk::FiberBundleX and two planar figures indicating the start end end point */ TractContainerType CreateTracts(mitk::FiberBundleX *fib, mitk::PlanarFigure* startRoi, mitk::PlanarFigure* endRoi); }; #endif diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.h index 42233fa086..c6a5ce32e3 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.h +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.h @@ -1,175 +1,178 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkTractbasedSpatialStatisticsView_h #define QmitkTractbasedSpatialStatisticsView_h #include #include "ui_QmitkTractbasedSpatialStatisticsViewControls.h" #include #include #include #include #include #include #include #include "QmitkTbssTableModel.h" #include "QmitkTbssMetaTableModel.h" #include // Image types typedef short DiffusionPixelType; typedef itk::Image CharImageType; typedef itk::Image UCharImageType; typedef itk::Image Float4DImageType; typedef itk::Image FloatImageType; typedef itk::VectorImage VectorImageType; // Readers/Writers typedef itk::ImageFileReader< CharImageType > CharReaderType; typedef itk::ImageFileReader< UCharImageType > UCharReaderType; typedef itk::ImageFileWriter< CharImageType > CharWriterType; typedef itk::ImageFileReader< FloatImageType > FloatReaderType; typedef itk::ImageFileWriter< FloatImageType > FloatWriterType; typedef itk::ImageFileReader< Float4DImageType > Float4DReaderType; typedef itk::ImageFileWriter< Float4DImageType > Float4DWriterType; /*! * \brief This plugin provides an extension for Tract-based spatial statistics (see Smith et al., 2009. http://dx.doi.org/10.1016/j.neuroimage.2006.02.024) * TBSS enables analyzing the brain by a pipeline of registration, skeletonization, and projection that results in a white matter skeleton - * for all subjects that are analyzed statistically. This plugin provides functionality to select single tracts and analyze them seperately. + * for all subjects that are analyzed statistically in a whole-brain manner. + * This plugin provides functionality to select single tracts and analyze them separately. + * + * Prerequisites: the mean_FA_skeleton and all_FA_skeletonised datasets produced by the FSL TBSS pipeline: http://fsl.fmrib.ox.ac.uk/fsl/fsl4.0/tbss/index */ class QmitkTractbasedSpatialStatisticsView : public QmitkFunctionality { Q_OBJECT public: static const std::string VIEW_ID; QmitkTractbasedSpatialStatisticsView(); virtual ~QmitkTractbasedSpatialStatisticsView(); virtual void CreateQtPartControl(QWidget *parent); /// \brief Creation of the connections of main and control widget virtual void CreateConnections(); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); /// \brief Called when the functionality is activated virtual void Activated(); virtual void Deactivated(); protected slots: // Creates Roi void CreateRoi(); void Clicked(const QPointF& pos); // Import of FSL TBSS data void TbssImport(); // Add a group as metadata. This metadata is required by the plotting functionality void AddGroup(); // Remove a group void RemoveGroup(); // Copies the values displayed in the plot widget to clipboard, i.e. exports the data void CopyToClipboard(); // Method to cut away parts of fiber bundles that should not be plotted. void Cut(); // Adjust plot widget void PerformChange(); protected: /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( std::vector nodes ); // Creates a plot using a 4D image containing the projections of all subjects and a region of interest void Plot(mitk::TbssImage*, mitk::TbssRoiImage*); void PlotFiberBundle(mitk::FiberBundleX* fib, mitk::Image* img, mitk::PlanarFigure* startRoi=NULL, mitk::PlanarFigure* endRoi=NULL); void PlotFiber4D(mitk::TbssImage*, mitk::FiberBundleX* fib, mitk::PlanarFigure* startRoi=NULL, mitk::PlanarFigure* endRoi=NULL); // Create a point set. This point set defines the points through which a region of interest should go void InitPointsets(); // Pointset and DataNode to contain the PointSet used in ROI creation mitk::PointSet::Pointer m_PointSetNode; mitk::DataNode::Pointer m_P1; // GUI widgets Ui::QmitkTractbasedSpatialStatisticsViewControls* m_Controls; /* A pointer to the QmitkStdMultiWidget. Used for interaction with the plot widget (clicking in the plot widget makes the image cross jump to the corresponding location on the skeleton).*/ QmitkStdMultiWidget* m_MultiWidget; // Used to save the region of interest in a vector of itk::index. std::vector< itk::Index<3> > m_Roi; mitk::FiberBundleX* m_Fib; mitk::Geometry3D* m_CurrentGeometry; // A table model for saving group information in a name,number pair. QmitkTbssTableModel* m_GroupModel; // Convenience function for adding a new image to the datastorage and giving it a name. void AddTbssToDataStorage(mitk::Image* image, std::string name); mitk::DataNode::Pointer m_CurrentFiberNode; // needed for the index property when interacting with the plot widget // needed when a plot should only show values between a start end end roi mitk::DataNode::Pointer m_CurrentStartRoi; mitk::DataNode::Pointer m_CurrentEndRoi; }; #endif // _QMITKTRACTBASEDSPATIALSTATISTICSVIEW_H_INCLUDED