diff --git a/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkAcquisitionType.h b/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkAcquisitionType.h index 93621848a5..24a7002828 100644 --- a/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkAcquisitionType.h +++ b/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkAcquisitionType.h @@ -1,68 +1,68 @@ /*=================================================================== 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 _MITK_KspaceReadout_H #define _MITK_KspaceReadout_H #include #include namespace mitk { /** * \brief Abstract class for k-space acquisiton type (k-space trajectory and echo placement) * */ class AcquisitionType { public: AcquisitionType(FiberfoxParameters* parameters) { m_Parameters = parameters; kxMax = static_cast(m_Parameters->m_SignalGen.m_CroppedRegion.GetSize(0)); kyMax = static_cast(m_Parameters->m_SignalGen.m_CroppedRegion.GetSize(1)); } virtual ~AcquisitionType(){} - virtual float GetTimeFromMaxEcho(itk::Index< 2 > index) = 0; ///< Time from maximum echo intensity in milliseconds - virtual float GetRedoutTime(itk::Index< 2 > index) = 0; ///< Time passed since readout started in milliseconds - virtual float GetTimeFromRf(itk::Index< 2 > index) = 0; ///< Time passed since RF pulse was applied in milliseconds - virtual itk::Index< 2 > GetActualKspaceIndex(itk::Index< 2 > index) = 0; ///< Transfer simple image iterator index to desired k-space index (depends on k-space readout scheme) + virtual float GetTimeFromMaxEcho(const itk::Index< 2 >& index) = 0; ///< Time from maximum echo intensity in milliseconds + virtual float GetRedoutTime(const itk::Index< 2 >& index) = 0; ///< Time passed since readout started in milliseconds + virtual float GetTimeFromRf(const itk::Index< 2 >& index) = 0; ///< Time passed since RF pulse was applied in milliseconds + virtual itk::Index< 2 > GetActualKspaceIndex(const itk::Index< 2 >& index) = 0; ///< Transfer simple image iterator index to desired k-space index (depends on k-space readout scheme) virtual void AdjustEchoTime() = 0; ///< Depending on the k-space readout scheme and acquisition parameters the minimum TE varies. This has to be checked and adjusted in this method. - itk::Index< 2 > GetSymmetricIndex(itk::Index< 2 >& index) const + itk::Index< 2 > GetSymmetricIndex(const itk::Index< 2 >& index) { itk::Index< 2 > sym; sym[0] = kxMax-index[0]-1; sym[1] = kyMax-index[1]-1; return sym; } protected: float m_NegTEhalf; ///< negative time to read half the k-space (needed to calculate the ms from the maximum echo); THIS IS NOT THE WELL KNOWN TE/2 SCANNER PARAMETER FiberfoxParameters* m_Parameters; itk::Size< 2 > m_Size; float dt; // time to read one k-space voxe int kxMax; int kyMax; }; } #endif diff --git a/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkConventionalSpinEcho.h b/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkConventionalSpinEcho.h index 5e1a176ea4..2586dfd695 100644 --- a/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkConventionalSpinEcho.h +++ b/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkConventionalSpinEcho.h @@ -1,88 +1,89 @@ /*=================================================================== 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 _MITK_ConventionalSpinEcho_H #define _MITK_ConventionalSpinEcho_H #include namespace mitk { /** * \brief Conventional spin echo sequence. Cartesian readout. One echo and one excitation per k-space line. * */ class ConventionalSpinEcho : public AcquisitionType { public: ConventionalSpinEcho(FiberfoxParameters* parameters) : AcquisitionType(parameters) { dt = m_Parameters->m_SignalGen.m_tLine/kxMax; // time to read one k-space voxel // maximum echo at center of each line m_NegTEhalf = -dt*(kxMax-kxMax%2)/2; } ~ConventionalSpinEcho() override {} // one echo per k-space line - float GetTimeFromMaxEcho(itk::Index< 2 > index) override + float GetTimeFromMaxEcho(const itk::Index< 2 >& index) override { float t = 0; t = m_NegTEhalf + static_cast(index[0])*dt; return t; } // time since current readout pulse started - float GetRedoutTime(itk::Index< 2 > index) override + float GetRedoutTime(const itk::Index< 2 >& index) override { return static_cast(index[0])*dt; } // time from max-echo + TE - float GetTimeFromRf(itk::Index< 2 > index) override + float GetTimeFromRf(const itk::Index< 2 >& index) override { return m_Parameters->m_SignalGen.m_tEcho + GetTimeFromMaxEcho(index); } - itk::Index< 2 > GetActualKspaceIndex(itk::Index< 2 > index) override + itk::Index< 2 > GetActualKspaceIndex(const itk::Index< 2 >& index) override { + itk::Index< 2 > out_idx = index; // reverse phase if (!m_Parameters->m_SignalGen.m_ReversePhase) - index[1] = kyMax-1-index[1]; + out_idx[1] = kyMax-1-out_idx[1]; - return index; + return out_idx; } void AdjustEchoTime() override { if ( m_Parameters->m_SignalGen.m_tEcho < m_Parameters->m_SignalGen.m_tLine ) { m_Parameters->m_SignalGen.m_tEcho = m_Parameters->m_SignalGen.m_tLine; MITK_WARN << "Echo time is too short! Time not sufficient to read slice. Automatically adjusted to " << m_Parameters->m_SignalGen.m_tEcho << " ms"; m_Parameters->m_Misc.m_AfterSimulationMessage += "Echo time was chosen too short! Time not sufficient to read slice. Internally adjusted to " + boost::lexical_cast(m_Parameters->m_SignalGen.m_tEcho) + " ms\n"; } } protected: }; } #endif diff --git a/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkFastSpinEcho.h b/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkFastSpinEcho.h index 0d8aa8131b..a70aa0ab01 100644 --- a/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkFastSpinEcho.h +++ b/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkFastSpinEcho.h @@ -1,91 +1,92 @@ /*=================================================================== 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 _MITK_FastSpinEcho_H #define _MITK_FastSpinEcho_H #include namespace mitk { /** * \brief Fast spin echo sequence. Cartesian readout. * Echo spacing = TE */ class FastSpinEcho : public AcquisitionType { public: FastSpinEcho(FiberfoxParameters* parameters) : AcquisitionType(parameters) { m_LinesWithSameTime = static_cast(std::ceil(static_cast(kyMax)/m_Parameters->m_SignalGen.m_EchoTrainLength)); dt = m_Parameters->m_SignalGen.m_tLine/kxMax; // time to read one k-space voxel // maximum echo at center of each line m_NegTEhalf = -dt*(kxMax-kxMax%2)/2; } ~FastSpinEcho() override {} // one echo per k-space line - float GetTimeFromMaxEcho(itk::Index< 2 > index) override + float GetTimeFromMaxEcho(const itk::Index< 2 >& index) override { return m_NegTEhalf + static_cast(index[0])*dt; } // time since current readout pulse started - float GetRedoutTime(itk::Index< 2 > index) override + float GetRedoutTime(const itk::Index< 2 >& index) override { return static_cast(index[0])*dt; } // depends on ETL - float GetTimeFromRf(itk::Index< 2 > index) override + float GetTimeFromRf(const itk::Index< 2 >& index) override { return m_Parameters->m_SignalGen.m_tEcho*std::ceil(static_cast(index[1]+1)/m_LinesWithSameTime) + GetTimeFromMaxEcho(index); } - itk::Index< 2 > GetActualKspaceIndex(itk::Index< 2 > index) override + itk::Index< 2 > GetActualKspaceIndex(const itk::Index< 2 >& index) override { + itk::Index< 2 > out_idx = index; // reverse phase if (!m_Parameters->m_SignalGen.m_ReversePhase) - index[1] = kyMax-1-index[1]; + out_idx[1] = kyMax-1-out_idx[1]; return index; } void AdjustEchoTime() override { if ( m_Parameters->m_SignalGen.m_tEcho < m_Parameters->m_SignalGen.m_tLine ) { m_Parameters->m_SignalGen.m_tEcho = m_Parameters->m_SignalGen.m_tLine; MITK_WARN << "Echo time is too short! Time not sufficient to read slice. Automatically adjusted to " << m_Parameters->m_SignalGen.m_tEcho << " ms"; m_Parameters->m_Misc.m_AfterSimulationMessage += "Echo time was chosen too short! Time not sufficient to read slice. Internally adjusted to " + boost::lexical_cast(m_Parameters->m_SignalGen.m_tEcho) + " ms\n"; } } protected: unsigned int m_LinesWithSameTime; }; } #endif diff --git a/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkSingleShotEpi.h b/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkSingleShotEpi.h index b5629ab8d5..bab5ef167a 100644 --- a/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkSingleShotEpi.h +++ b/Modules/DiffusionImaging/FiberTracking/Fiberfox/Sequences/mitkSingleShotEpi.h @@ -1,99 +1,100 @@ /*=================================================================== 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 _MITK_SingleShotEpi_H #define _MITK_SingleShotEpi_H #include namespace mitk { /** * \brief Realizes EPI readout: one echo, maximum intensity in the k-space center, zig-zag trajectory * */ class SingleShotEpi : public AcquisitionType { public: SingleShotEpi(FiberfoxParameters* parameters) : AcquisitionType(parameters) { dt = m_Parameters->m_SignalGen.m_tLine/kxMax; // time to read one k-space voxel // k-space center at maximum echo if ( kyMax%2==0 ) { m_NegTEhalf = -m_Parameters->m_SignalGen.m_tLine*(kyMax-1)/2 + dt*(kxMax-kxMax%2)/2; } else m_NegTEhalf = -m_Parameters->m_SignalGen.m_tLine*(kyMax-1)/2 - dt*(kxMax-kxMax%2)/2; } ~SingleShotEpi() override {} // one echo per slice - float GetTimeFromMaxEcho(itk::Index< 2 > index) override + float GetTimeFromMaxEcho(const itk::Index< 2 >& index) override { float t = 0; t = m_NegTEhalf + (static_cast(index[1])*kxMax+static_cast(index[0]))*dt; return t; } - float GetRedoutTime(itk::Index< 2 > index) override + float GetRedoutTime(const itk::Index< 2 >& index) override { float t = 0; t = (static_cast(index[1])*kxMax+static_cast(index[0]))*dt; return t; } - float GetTimeFromRf(itk::Index< 2 > index) override + float GetTimeFromRf(const itk::Index< 2 >& index) override { return m_Parameters->m_SignalGen.m_tEcho + GetTimeFromMaxEcho(index); } - itk::Index< 2 > GetActualKspaceIndex(itk::Index< 2 > index) override + itk::Index< 2 > GetActualKspaceIndex(const itk::Index< 2 >& index) override { + itk::Index< 2 > out_idx = index; // reverse phase if (!m_Parameters->m_SignalGen.m_ReversePhase) - index[1] = kyMax-1-index[1]; + out_idx[1] = kyMax-1-out_idx[1]; // reverse readout direction - if (index[1]%2 == 1) - index[0] = kxMax-index[0]-1; + if (out_idx[1]%2 == 1) + out_idx[0] = kxMax-out_idx[0]-1; - return index; + return out_idx; } void AdjustEchoTime() override { auto temp = m_Parameters->m_SignalGen.m_CroppedRegion.GetSize(1)*m_Parameters->m_SignalGen.m_PartialFourier - (m_Parameters->m_SignalGen.m_CroppedRegion.GetSize(1)+m_Parameters->m_SignalGen.m_CroppedRegion.GetSize(1)%2)/2; if ( m_Parameters->m_SignalGen.m_tEcho/2 < temp*m_Parameters->m_SignalGen.m_tLine ) { m_Parameters->m_SignalGen.m_tEcho = 2*temp*m_Parameters->m_SignalGen.m_tLine; MITK_WARN << "Echo time is too short! Time not sufficient to read slice. Automatically adjusted to " << m_Parameters->m_SignalGen.m_tEcho << " ms"; m_Parameters->m_Misc.m_AfterSimulationMessage += "Echo time was chosen too short! Time not sufficient to read slice. Internally adjusted to " + boost::lexical_cast(m_Parameters->m_SignalGen.m_tEcho) + " ms\n"; } } protected: }; } #endif