Fwd: Re: [Insight-users] Inhomogenity correction using MRIBiasField Correction
Jisung Kim
bahrahm at yahoo . com
Mon, 5 Aug 2002 06:36:52 -0700 (PDT)
--- Jisung Kim <bahrahm@yahoo.com> wrote:
> Date: Mon, 5 Aug 2002 06:35:24 -0700 (PDT)
> From: Jisung Kim <bahrahm@yahoo.com>
> Subject: Re: [Insight-users] Inhomogenity correction
> using MRIBiasField Correction
> To: cspl <affable@hd2.dot.net.in>
>
> Hello.
>
> I think you should create the mean and sigma array
> with specific array size. In you case, The mean
> array
> creation statement should looks like this:
>
> itk::Array<double> *classMeans = new
> itk::Array<double>(2);
>
> itk::Array<double> *classSigmas= new
> itk::Array<double>(2) ;
>
> Thank you,
>
> Jisung Kim.
>
> --- cspl <affable@hd2.dot.net.in> wrote:
> > Dear Mr.bjorn & Friends,
> >
> > I am working on itkMRIBiasFieldCorrectionFilter.I
> > got hte problem with array to assign mean and
> sigma
> > values. I got exception while running at setting
> > parameters like as follows.
> >
> > Volume* CIPServerDoc::Inhomogenity(Volume
> > *vol,Volume *mask)
> > {
> > if (vol == NULL) return vol;
> > short *Buffer = new short[vol->width *
> vol->height
> > * vol->depth];
> > short *Buffer1 = new short[mask->width *
> > mask->height * mask->depth];
> >
> > Buffer = (short *) vol->Mem;
> > Buffer1= (short *) mask->Mem;
> >
> > typedef itk::Image<float,3> ImageType;
> > typedef itk::Image<float,3> ImageType1;
> > typedef itk::Image<float,3> ImageType2;
> >
> > itk::RawImageIO<float, 3>::Pointer output_io
> > = itk::RawImageIO<float, 3>::New();
> >
> > output_io->SetByteOrderToLittleEndian();
> > output_io->SetFileTypeToBinary();
> > output_io->SetFileDimensionality(3);
> >
> > // Initialize the initial and target volumes.
> > ImageType::Pointer vol_init =
> > ImageType::New();
> > ImageType1::Pointer vol_init1 =
> ImageType1::New();
> > ImageType2::Pointer vol_init2 =
> ImageType2::New();
> >
> >
> > ImageType::SizeType sz;
> > sz[0] = vol->width;
> > sz[1] = vol->height;
> > sz[2]=vol->depth;
> >
> > ImageType1::SizeType sz1;
> > sz1[0] = mask->width;
> > sz1[1] = mask->height;
> > sz1[2]= mask->depth;
> >
> >
> > ImageType::IndexType idx;
> > idx[0] = 0;
> > idx[1] = 0;
> > idx[2] = 0 ;
> >
> > ImageType1::IndexType idx1;
> > idx1[0] = 0;
> > idx1[1] = 0;
> > idx1[2] = 0 ;
> >
> > ImageType::RegionType reg;
> > reg.SetSize(sz);
> > reg.SetIndex(idx);
> >
> > ImageType1::RegionType reg1;
> > reg.SetSize(sz1);
> > reg.SetIndex(idx1);
> >
> > vol_init->SetRegions(reg);
> > vol_init1->SetRegions(reg1);
> > vol_init2->SetRegions(reg);
> > vol_init->Allocate();
> > vol_init1->Allocate();
> > vol_init2->Allocate();
> >
> >
> >
> > for(int z=0; z<vol->depth; ++z )
> > {
> > idx[2]=z;
> >
> > for (int y = 0; y < vol->height; ++y)
> > {
> > idx[1] = y;
> > for (int x = 0; x < vol->width; ++x)
> > {
> > idx[0] = x;
> > vol_init->SetPixel(idx, *(Buffer
> > +(z*vol->height*vol->width)+y *vol->width +x));
> > }
> > }
> >
> > }
> >
> >
> > ////mask
> > for(int z1=0; z1<mask->depth; ++z1 )
> > {
> > idx1[2]=z1;
> > for (int y1 = 0; y1<mask->height; ++y1)
> > {
> > idx1[1] = y1;
> > //AfxMessageBox("in mask height loop");
> > for (int x1=0; x1 < mask->width; ++x1)
> > {
> > idx1[0] = x1;
> > vol_init2->SetPixel(idx1,*(Buffer1
> > +(z1*mask->height*mask->width)+y1 *mask->width
> > +x1));
> > }
> >
> > }
> >
> > }
> >
> > typedef
> >
>
BiasFieldCorrectionFilter<ImageType,ImageType,ImageType1>
> >
> > Corrector;
> > Corrector::Pointer filter = Corrector::New() ;
> > //parameters initiliazation
> > bool useLog = true;
> > int degree = 3;
> > int sliceDirection = 2;
> >
> >
> > vnl_vector<double> coefficientVector ;
> > itk::Array<double> *classMeans = new
> > itk::Array<double>;
> >
> > classMeans[0]=1500;
> > classMeans[1]=570;
> >
> > itk::Array<double> *classSigmas= new
> > itk::Array<double> ;
> > classSigmas[0]=100;
> > classSigmas[1]=70;
> >
> > int volumeMaximumIteration = 2000;
> > int interSliceMaximumIteration = 20;
> > // double initialRadius ;
> > double growth = 1.05;
> > double shrink = 0.0;
> > AfxMessageBox("before set input");
> > filter->SetInput(vol_init);
> > filter->SetInputMask(vol_init2);
> >
> >
> > filter->IsBiasFieldMultiplicative(useLog) ;
> >
>
///////////////////////////////////////////////////////////////////////
> >
> >
>
filter->SetTissueClassStatistics(*classMeans,*classSigmas)
> > ;/// /* here Getting exception */
> >
>
//////////////////////////////////////////////////////////////////////
> >
> > filter->SetOptimizerGrowthFactor(growth) ;
> >
> > filter->SetOptimizerShrinkFactor(shrink) ;
> >
> >
> >
>
filter->SetVolumeCorrectionMaximumIteration(volumeMaximumIteration)
> > ;
> >
> >
> >
>
//filter->SetInterSliceCorrectionMaximumIteration(interSliceMaximumIteration)
> > ;
> >
> //filter->SetOptimizerInitialRadius(initialRadius)
> > ;
> > filter->SetBiasFieldDegree(degree) ;
> >
> > //
> >
>
filter->SetUsingSlabIdentification(usingSlabIdentification)
> > ;
> > filter->SetSlicingDirection(sliceDirection) ;
> >
> >
> > AfxMessageBox("before update");
> > filter->Update();
> >
> > vol_init2=filter->GetOutput();
> >
> > for(unsigned int z=0; z<vol->depth; ++z )
> > {
> > idx[2]=z;
> >
> > for (unsigned int y = 0; y < vol->height;
> ++y)
> > {
> > idx[1] = y;
> > for (unsigned int x = 0; x < vol->width;
> > ++x)
> > {
> > idx[0] = x;
> > *(Buffer
> +(z*vol->height*vol->width)+y
> > *vol->width +x)=vol_init->GetPixel(idx);
> > }
> > }
> > }
> >
> > vol->Mem = Buffer;
> > return vol;
> >
> > }
> >
> >
> === message truncated ===
>
>
> =====
> Jisung Kim
> bahrahm@yahoo.com
> 106 Mason Farm Rd.
> 129 Radiology Research Lab., CB# 7515
> Univ. of North Carolina at Chapel Hill
> Chapel Hill, NC 27599-7515
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - Feel better, live better
> http://health.yahoo.com
>
=====
Jisung Kim
bahrahm@yahoo.com
106 Mason Farm Rd.
129 Radiology Research Lab., CB# 7515
Univ. of North Carolina at Chapel Hill
Chapel Hill, NC 27599-7515
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com