示例#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 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;
}
示例#3
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;
}
示例#4
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;
}
示例#5
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;
}