Пример #1
0
typename AstroStickModel< ScalarType >::PixelType AstroStickModel< ScalarType >::SimulateMeasurement()
{
    PixelType signal;
    signal.SetSize(this->m_GradientList.size());
    double b = -m_BValue*m_Diffusivity;

    if (m_RandomizeSticks)
        m_NumSticks = 30 + m_RandGen->GetIntegerVariate()%31;

    for( unsigned int i=0; i<this->m_GradientList.size(); i++)
    {
        GradientType g = this->m_GradientList[i];
        double bVal = g.GetNorm(); bVal *= bVal;

        if (bVal>0.0001)
        {
            for (int j=0; j<m_NumSticks; j++)
            {
                double dot = 0;
                if(m_RandomizeSticks)
                    dot = GetRandomDirection()*g;
                else
                    dot = m_Sticks[j]*g;
                signal[i] += exp( b*bVal*dot*dot );
            }
            signal[i] /= m_NumSticks;
        }
        else
            signal[i] = 1;
    }

    return signal;
}
Пример #2
0
typename AstroStickModel< ScalarType >::GradientType AstroStickModel< ScalarType >::GetRandomDirection()
{
    GradientType vec;
    vec[0] = m_RandGen->GetNormalVariate();
    vec[1] = m_RandGen->GetNormalVariate();
    vec[2] = m_RandGen->GetNormalVariate();
    vec.Normalize();
    return vec;
}
Пример #3
0
typename TensorModel< ScalarType >::PixelType TensorModel< ScalarType >::SimulateMeasurement()
{
    PixelType signal;
    signal.SetSize(this->m_GradientList.size());
    signal.Fill(0.0);

    ItkTensorType tensor;
    tensor.Fill(0.0);
    this->m_FiberDirection.Normalize();
    vnl_vector_fixed<double, 3> axis = itk::CrossProduct(m_KernelDirection, this->m_FiberDirection).GetVnlVector();
    axis.normalize();
    vnl_quaternion<double> rotation(axis, acos(m_KernelDirection*this->m_FiberDirection));
    rotation.normalize();
    vnl_matrix_fixed<double, 3, 3> matrix = rotation.rotation_matrix_transpose();

    vnl_matrix_fixed<double, 3, 3> tensorMatrix = matrix.transpose()*m_KernelTensorMatrix*matrix;
    tensor[0] = tensorMatrix[0][0];
    tensor[1] = tensorMatrix[0][1];
    tensor[2] = tensorMatrix[0][2];
    tensor[3] = tensorMatrix[1][1];
    tensor[4] = tensorMatrix[1][2];
    tensor[5] = tensorMatrix[2][2];

    for( unsigned int i=0; i<this->m_GradientList.size(); i++)
    {
        GradientType g = this->m_GradientList[i];
        ScalarType bVal = g.GetNorm();
        bVal *= bVal;

        if (bVal>0.0001)
        {
            itk::DiffusionTensor3D< ScalarType > S;
            S[0] = g[0]*g[0];
            S[1] = g[1]*g[0];
            S[2] = g[2]*g[0];
            S[3] = g[1]*g[1];
            S[4] = g[2]*g[1];
            S[5] = g[2]*g[2];

            ScalarType D = tensor[0]*S[0] + tensor[1]*S[1] + tensor[2]*S[2] +
                           tensor[1]*S[1] + tensor[3]*S[3] + tensor[4]*S[4] +
                           tensor[2]*S[2] + tensor[4]*S[4] + tensor[5]*S[5];

            // check for corrupted tensor and generate signal
            if (D>=0)
                signal[i] = exp ( -m_BValue * bVal * D );
        }
        else
            signal[i] = 1;
    }

    return signal;
}
Пример #4
0
typename BallModel< ScalarType >::PixelType BallModel< ScalarType >::SimulateMeasurement()
{
    PixelType signal;
    signal.SetSize(this->m_GradientList.size());

    for( unsigned int i=0; i<this->m_GradientList.size(); i++)
    {
        GradientType g = this->m_GradientList[i];
        if (g.GetNorm()>0.0001)
            signal[i] = exp( -m_BValue * m_Diffusivity );
        else
            signal[i] = 1;
    }

    return signal;
}
Пример #5
0
ScalarType BallModel< ScalarType >::SimulateMeasurement(int dir)
{
    ScalarType signal = 0;

    if (dir>=this->m_GradientList.size())
        return signal;

    GradientType g = this->m_GradientList[dir];
    ScalarType bVal = g.GetNorm(); bVal *= bVal;

    if (bVal>0.0001)
        signal = exp( -m_BValue * bVal * m_Diffusivity );
    else
        signal = 1;

    return signal;
}
Пример #6
0
AstroStickModel< ScalarType >::AstroStickModel()
    : m_Diffusivity(0.001)
    , m_BValue(1000)
    , m_NumSticks(42)
    , m_RandomizeSticks(false)
{
    m_RandGen = ItkRandGenType::New();

    vnl_matrix_fixed<double,3,42>* sticks = itk::PointShell<42, vnl_matrix_fixed<double, 3, 42> >::DistributePointShell();
    for (int i=0; i<m_NumSticks; i++)
    {
        GradientType stick;
        stick[0] = sticks->get(0,i); stick[1] = sticks->get(1,i); stick[2] = sticks->get(2,i);
        stick.Normalize();
        m_Sticks.push_back(stick);
    }
}
Пример #7
0
ScalarType StickModel< ScalarType >::SimulateMeasurement(unsigned int dir, GradientType& fiberDirection)
{
  ScalarType signal = 0;

  if (dir>=this->m_GradientList.size())
    return signal;

  GradientType g = this->m_GradientList[dir];
  if (g.GetNorm()>0.0001)
  {
    ScalarType dot = fiberDirection*g;
    signal = std::exp( -this->m_BValue*m_Diffusivity*dot*dot ); // skip * bVal becaus bVal is already encoded in the dot product (norm of g encodes b-value relative to baseline b-value m_BValue)
  }
  else
    signal = 1;

  return signal;
}
Пример #8
0
typename StickModel< ScalarType >::PixelType StickModel< ScalarType >::SimulateMeasurement(GradientType &fiberDirection)
{
  PixelType signal;
  signal.SetSize(this->m_GradientList.size());

  for( unsigned int i=0; i<this->m_GradientList.size(); i++)
  {
    GradientType g = this->m_GradientList[i];
    if (g.GetNorm()>0.0001)
    {
      ScalarType dot = fiberDirection*g;
      signal[i] = std::exp( -this->m_BValue*m_Diffusivity*dot*dot ); // skip * bVal becaus bVal is already encoded in the dot product (norm of g encodes b-value relative to baseline b-value m_BValue)
    }
    else
      signal[i] = 1;
  }

  return signal;
}
Пример #9
0
typename DwiPhantomGenerationFilter< TOutputScalarType >::OutputImageType::PixelType
DwiPhantomGenerationFilter< TOutputScalarType >::SimulateMeasurement(itk::DiffusionTensor3D<float>& T, float weight)
{
    typename OutputImageType::PixelType out;
    out.SetSize(m_GradientList.size());
    out.Fill(0);

    TOutputScalarType s0 = m_DefaultBaseline;
    if (m_SimulateBaseline)
        s0 = (GetTensorL2Norm(T)/m_MaxBaseline)*m_SignalScale;

    for( unsigned int i=0; i<m_GradientList.size(); i++)
    {
        GradientType g = m_GradientList[i];

        if (g.GetNorm()>0.0001)
        {
            itk::DiffusionTensor3D<float> S;
            S[0] = g[0]*g[0];
            S[1] = g[1]*g[0];
            S[2] = g[2]*g[0];
            S[3] = g[1]*g[1];
            S[4] = g[2]*g[1];
            S[5] = g[2]*g[2];

            double D = T[0]*S[0] + T[1]*S[1] + T[2]*S[2] +
                       T[1]*S[1] + T[3]*S[3] + T[4]*S[4] +
                       T[2]*S[2] + T[4]*S[4] + T[5]*S[5];

            // check for corrupted tensor and generate signal
            if (D>=0)
            {
                D = weight*s0*exp ( -m_BValue * D );
                out[i] = static_cast<TOutputScalarType>( D );
            }
        }
        else
            out[i] = s0;
    }

    return out;
}
Пример #10
0
typename StickModel< ScalarType >::PixelType StickModel< ScalarType >::SimulateMeasurement()
{
    PixelType signal;
    signal.SetSize(this->m_GradientList.size());

    for( unsigned int i=0; i<this->m_GradientList.size(); i++)
    {
        GradientType g = this->m_GradientList[i];
        double bVal = g.GetNorm(); bVal *= bVal;

        if (bVal>0.0001)
        {
            double dot = this->m_FiberDirection*g;
            signal[i] = exp( -m_BValue * bVal * m_Diffusivity*dot*dot );
        }
        else
            signal[i] = 1;
    }

    return signal;
}
Пример #11
0
ScalarType StickModel< ScalarType >::SimulateMeasurement(unsigned int dir)
{
    ScalarType signal = 0;

    if (dir>=this->m_GradientList.size())
        return signal;

    this->m_FiberDirection.Normalize();

    GradientType g = this->m_GradientList[dir];
    ScalarType bVal = g.GetNorm(); bVal *= bVal;

    if (bVal>0.0001)
    {
        ScalarType dot = this->m_FiberDirection*g;
        signal = exp( -m_BValue * bVal * m_Diffusivity*dot*dot );
    }
    else
        signal = 1;

    return signal;
}
Пример #12
0
Real
InitialConditionTempl<RealVectorValue>::dotHelper(const GradientType & op1,
                                                  const GradientType & op2)
{
  return op1.contract(op2);
}