[Insight-developers] ITK code style
Miller, James V (Research)
millerjv at crd.ge.com
Tue, 27 Apr 2004 09:23:09 -0400
I am going to suggest that the OUTPUTS of the PCAShapeModelEstimator
be passed as inputs to the projection code as opposed to the
PCAShapeModelEstimator being passed. The PCAShapeModelEstimator is
an ImageToImageFilter, so it is already part of the pipeline
process.
This requires that the user pass the "right" outputs of the
PCAShapeModelEstimator to the inputs of projection code. But this
seems reasonable to me because in PCA, sometimes you project onto the
set of eigenvectors with the highest eigenvalues and sometimes you
project onto the eigenvectors with the lowest eigenvalues.
To make things convenient, you could have a "bulk" connection
methods on the projection filter, something like
/**
* Connect the first "k" spanning vectors in the specified vector as the
* inputs to this filter. This is a convenience method to be used in place
* of SetNthInput().
*/
void SetSpanningVectors(const std::vector<DataObjectPointer> &inputs,
unsigned int k);
I don't want to call this SetInputs() since that may be too confusing.
It would be used like:
projection->SetSpanningVectors( pcaEstimator->GetOutputs(), Nsubspace );
where Nsubspace <= estimator->GetNumberOfPrincipalComponentsRequired();
The tricky part to doing things this way is that the PCAShapeEstimator has
to create the proper number of outputs (prior to a call to Update() ). But
it
looks to me that this done by the
estimator->SetNumberOfPrincipalComponentsRequired() method.
-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
Sent: Monday, April 26, 2004 10:25 PM
To: Zachary Pincus
Cc: insight-developers at itk.org
Subject: Re: [Insight-developers] ITK code style
Hi Zach,
1) You can use an ImageAdaptor, instead of a CastImageFilter.
Unless you plan to visit the pixels of this image many
times. Adaptors are a convenient way of changing the
pixel representation without having to duplicate memory.
You will find a chapter on ImageAdaptors in the SoftwareGuide.
2) One nice advantage of Extreme Programming is the recognition
that it is almost impossible to get things right the first
time. It is therefore more important to the *one* version
working, and then let it evolve according to the feedback
from other users. I would suggest you follow the simplest
implementation first. In this case it seems to be the option
in which you pass the PCAShapeModelEstimator as input to
the PCA projection filter.
Generalization in ITK is usually achieved by first commiting
a particular version of a class. Once in the repository, it
is easier to work with other developers in order to blend it
better with other components in the tookit, and make it more
general.
Please let us know if you have further questions.
Regards.
Luis
----------------------
Zachary Pincus wrote:
> Hello,
>
> I'm working on a class that I think I might submit for inclusion in ITK.
> (Specifically, a class that calculates the projection of an image into
> the space described by an orthonormal basis set, e.g. the output of PCA
> analysis).
>
> Anyhow, I had a couple of questions on what I ought to do to conform to
> ITK's style, etc.
>
> First, a CastImageFilter will be needed for this computation, except in
> the case when the template output and input image types are the same. To
> what extent does/should ITK code try to detect these cases and skip
> unnecessary steps? (And if this is recommended, is there a good
> mechanism for doing so? All I can think of is a templated function
> AreTheSame<TypeA, TypeB>() that returns false except in the few special
> cases I implement manually... And that seems a bit nasty.)
>
> Second, my class needs basically all the output from a
> PCAShapeModelEstimator. Projecting into a space described by a basis set
> is a general task, but from the ITK perspective, this pretty much is
> only necessary in the PCA case. Anyhow, I could have my class take as
> input either (a) a series of images that consist of a portion of the
> output from a PCAShapeModelEstimator, or (b) the class could just take a
> reference to the PCAShapeModelEstimator itself. The latter option is
> attractive, since it will be impossible for users to do the wrong thing
> and send the wrong part of the Estimator's output to my class. But it
> seems a bit at variance to the way things are done in ITK. Does anyone
> have guidance for this case?
>
> Thanks,
>
> Zach Pincus
>
> Department of Biochemistry and Program in Biomedical Informatics
> Stanford University School of Medicine
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>
_______________________________________________
Insight-developers mailing list
Insight-developers at itk.org
http://www.itk.org/mailman/listinfo/insight-developers