-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageMath strange results #12
Comments
casting looks like the problem there - all the ants programs are expecting we are likely to "hide" imagemath in the future and go to iMath instead ... brian On Wed, Feb 11, 2015 at 4:48 PM, Arman Eshaghi notifications@github.com
|
Was thinking about the iMath issue today. Would it make more sense to have On Wed, Feb 11, 2015 at 5:08 PM, stnava notifications@github.com wrote:
|
Not sure. This is a weird result (to me, at least): gives:
On 11 February 2015 at 17:08, stnava notifications@github.com wrote:
|
oh dear, there is a deeper problem, I think. We need to dig deep into ITK code. |
would probably be output <- imageBinaryDilation( input, 2 ) issue would be documenting all of the functions ... iMath sort of masks that need. if this is the direction one wants to go, that's fine but then we can eliminate ImageMath altogether ( which means taking it out of the "core" ants program list ) i started work on this but didnt get very far ... anyway, steps would be:
this would take some time but i'd be all for it ... one hidden danger is that this might lead to lots of R CMD check issues depending on what ends up in the .o file ... however, if we have our own flattened itk version anyway, these would be relatively easy to resolve |
i would like to get rid of imagemath in antsr b/c it is the single largest file and b/c it takes forever to compile ... not sure how much of it we actually use - seems like about 10% ... so would rather implement that 10% elsewhere |
Agreed, it's a bit of a behemoth. The iMath approach only partially masks On Wed, Feb 11, 2015 at 5:29 PM, stnava notifications@github.com wrote:
|
@bkandel - example 1 looks fine example 2 is sort of undefined.... brian On Wed, Feb 11, 2015 at 5:19 PM, bkandel notifications@github.com wrote:
|
i think there is some problem in the class of operators in which addtozero lives ... not sure what |
Oh, I see. I misunderstood what an image negative is. On 11 February 2015 at 17:40, stnava notifications@github.com wrote:
|
@jeffduda seems this is what we use from ImageMath CompCorrAuto, D, FastMarchingExtension, FillHoles, G, GD, GE, attached is a starter iMath.cpp brian On Wed, Feb 11, 2015 at 5:43 PM, bkandel notifications@github.com wrote:
|
Thanks @stnava we'll look into that |
didn't get attachment. maybe start new branch for this? On Wed, Feb 11, 2015 at 5:50 PM, stnava notifications@github.com wrote:
|
sure - will email it brian On Wed, Feb 11, 2015 at 5:59 PM, Jeffrey Duda notifications@github.com
|
i've been thinking more about this iMath utility ... here is a relevant example (i.e. there is precedent in R): http://topepo.github.io/caret/modelList.html for iMath to be really useful / interesting, it would have to be accompanied by a table like this that explains each operation. could be stored in a dataframe. otherwise, i can imagine an explosion of different functions that would be ever growing ... any thoughts appreciated. |
I agree. I think that a "Swiss army knife" function would actually be A major difficulty is that we don't have a method for having namespaces or On 12 February 2015 at 12:14, stnava notifications@github.com wrote:
|
I think the documentation is the biggest issue. My suggestion for going On Thu, Feb 12, 2015 at 1:35 PM, bkandel notifications@github.com wrote:
|
i think the caret solution is fine - it's just a dataframe that organizes that makes it (relatively) easy to test, maintain and visualize e.g. on the e.g. OperationName | OperationType | Arguments(free text) | Notes e.g. "" OperationName | OperationType | Arguments(free text) | Notes GetLargestComponent | Laplacian | brian On Thu, Feb 12, 2015 at 1:47 PM, Jeffrey Duda notifications@github.com
|
I think the c3d documentation ( On 12 February 2015 at 13:47, Jeffrey Duda notifications@github.com wrote:
|
c3d has some nice features but i think the documentation is too unstructured the data frame is good b/c one can do: for ( each operation in imath$operationtype == "SpatialFiltering" ) etc ... this will let us automate things nicely and generally brian On Thu, Feb 12, 2015 at 1:56 PM, bkandel notifications@github.com wrote:
|
let me bring up another point - this structure (generically) can be used to http://www.r-bloggers.com/converting-a-string-to-a-variable-name-on-the-fly-and-vice-versa-in-r/ in antsr, we could do iExpression( list(i1=img1,i2=img2,i3=img3) , xp=" ( i1 + i2 )/ i3 " ) this would require us to define math operations on the raw images or, this could be combined with iMath output to produce something very powerful brian On Thu, Feb 12, 2015 at 2:04 PM, brian avants stnava@gmail.com wrote:
|
This is much better (i.e. easier to understand) for users. On a related note, in R would it be possible to perform operator overloading, so that we could just type (antsImage1 + antsImage2)/antsImage3 ? |
We could implement an antsImage friendly version of formula() so it could On Thu, Feb 12, 2015 at 2:48 PM, Arman Eshaghi notifications@github.com
|
Yes! That sounds like a great idea to me. It's already implemented for On 12 February 2015 at 14:48, Arman Eshaghi notifications@github.com
|
I think all of these revolve around working on antsImage class more and more. I believe, ImageMath has its functionality inside shell, not in R. |
It's probably worth thinking about how much we want to enforce physical On Thu, Feb 12, 2015 at 3:00 PM, Arman Eshaghi notifications@github.com
|
there is always a compromise between the comfort of users and developers :-) |
glad you guys think this is doable - it will take just a little time, at the moment, i'd rather review code than write it .... brian On Thu, Feb 12, 2015 at 3:08 PM, Arman Eshaghi notifications@github.com
|
@jeffduda there was a recent SetGlobalTolerance flag added to itk that brian On Thu, Feb 12, 2015 at 3:16 PM, brian avants stnava@gmail.com wrote:
|
I already did most of the atomic vectors. Should be pushed as soon as I On 12 February 2015 at 15:17, stnava notifications@github.com wrote:
|
Yes talk is cheap, I will take this on the branch under my name and send a PR for review when done. First start with + and - , and then extend it to * and / |
sorry our message crossed @bkandel . Okay please move on with this... |
OK, I pushed the changes to add atomic vector operations (+ - * / ^ %%) for On 12 February 2015 at 15:24, Arman Eshaghi notifications@github.com
|
I just added methods for adding numbers to images, and documentation. See On 12 February 2015 at 16:58, Ben Kandel ben.kandel@sbcglobal.net wrote:
|
This will be really useful. How does division work with masked images? This is a problem in c3d because anything divided by zero becomes NaN, and attempting to mask out NaN after the fact doesn't work because NaN * 0 = NaN. On Feb 12, 2015, at 6:08 PM, bkandel notifications@github.com wrote:
|
I didn't do any special error handling. You can just mask out any parts you On 12 February 2015 at 18:12, Philip Cook notifications@github.com wrote:
|
i think exp and log would be good too |
ok i did a first pass on a dataframe based documentation / organization of iMath e.g. if you run
you get a (hopefully) meaningful output - ideally iMath would use the dataframe to guide the operations through the appropriate steps s.t. you actually check input and get correct dataframe output in this case but that's not implemented yet ... you can also do:
and get an image output in https://github.com/stnava/ANTsR/blob/master/data/iMathOps.csv see |
probably need to enumerate which operations take an additional image (or more) as input ... |
I think the more we limit this function, the more useful it would be. I think that it would be reasonable to have a separate function for On 17 February 2015 at 11:38, stnava notifications@github.com wrote:
|
@bkandel - your suggestion is basically what's done when one combines the iMath.R and the iMathOps.csv .... the operations are cataloged by type so it's (relatively) easy to see which go together. these could trivially be sorted by type as well .... agree that there should be an the current operation types are:
all of this is available in ImageMath ( iMath ) w/o much additional work / maintenance .... splitting these up would indeed be better but would impact many different programs in ANTsR.... resulting code base would not be backward compatible ( maybe not a big deal at this early stage ) .... regardless, the csv https://github.com/stnava/ANTsR/blob/master/data/iMathOps.csv captures the majority of operations that we would need to be available in antsr to help us do studies of asymmetry, prediction, segmentation etc that we all have on our hands ..... the major steps are:
anyway, i implemented the "old school" approach as an example for all to see and because progress was minimal ... am sort of chomping at the bit to move on to the next stage ( cran submission ) and this is, afaik, the major (user obvious) design issue at this moment. |
@stnava Should there be a separate vignette for this? I prefer imath.Rmd for example. Happy to work on this. |
That would be a very helpful project .... Just be aware that examples should be fast and that design may change. So
|
It looks like iMath currently just wraps ImageMath. If the only difference On 17 February 2015 at 14:23, stnava notifications@github.com wrote:
|
We only use about 10% of the function and it adds to compile time. So
|
am going to make another pass through iMath dox and restrict to just "image in, image out" operations, possibly with an attempt to handle multiple image inputs ... will update later. |
Goal: test
ImageMath
foraddtozero
:from man:
Reproducible example:
so:
and:
Moving on:
I would expect to get a homogenous array with 2s, but:
to check if casting could be a problem:
ImageMath.cxx:
Ideas?
Arman
The text was updated successfully, but these errors were encountered: