Git Product home page Git Product logo

Comments (19)

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

Ah, found out that the RandomSparseMask ImageSampler should only be used with a fixed image mask.

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

Hi Jorrit!

xout is indeed problematic and I am afraid that it is tied to the implementation of elastix itself. xout lives as as a global object outside the elastix namespace and thus is not tied to lifetime of the elastix class. Instead, any open xout buffers have to be closed manually after elastix as run. This wasn't a problem when elastix was an executable because the OS would close these buffers regardless of how the process would exit (as long as it exits). SimpleElastix has to manage these connections manually (read: I have to hack elastix) which is also why we don't use the vanilla elastix version.

It boils down the fact that xout is not closed if SimpleElastix crashes before finishing because that part of the code isn't reached, and instead xout dangles for as long as the host executable is running, e.g. your python session. The error you see is because xout tries to open the same buffers twice.

Perhaps it is possible to call the xout close code during error handling. Can you weigh in on this @mstaring? Would this be a feasible approach?

Not being able to assign parameters inside a parameter map list is known issue that is possibly tied to SWIG generated code. I don't know what to do about that :/

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

Hi!

Thanks for your fast response! Is it possible to expose the xoutClose, so I can call it when I know there is an error? Or wouldn't that work?

And indeed, not being able to assign parameters inside a parameter map list was my problem, but just getting them and modifying works, so not a real problem 😊

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

What about this issue? Does fix work?

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

I am currently in the middle of rewriting some code πŸ˜‹, but I'll test it soon!

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

πŸ‘

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

I'm still receiving the error using transformix (haven't tested elastix), is that right?

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

Can you send a minimum viable example (a few lines of code and example data) to [email protected] so I can test locally?

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

Yes, will have to be this weekend or next week. Have to work on another project next couple days :(

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

Np!

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

I've tried it up to 9574263, and it still fails. But I see you already have a newer version, so it's compiling! πŸ˜‹

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

I'm running it from iPython right now and it crashes after every registration. I'll try to gather some debug info.

Edit:
Hmm, it stops with a Segmentation fault: 11

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

If you send me a minimum viable example that reproduces the problem I will take a look!

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

Sorry for the delay, but this example fails for me with commit c98a803:

import SimpleITK as sitk

def register(fixed, moving):
    selx = sitk.SimpleElastix()
    selx.LogToConsoleOn()

    affine = sitk.GetDefaultParameterMap('affine')
    affine['RequiredRatioOfValidSamples'] = ("0.99",) # Make it fail :P

    plist = sitk.ParameterMapList()
    plist.append(affine)

    selx.SetParameterMap(plist)
    selx.SetFixedImage(fixed)
    selx.SetMovingImage(moving)

    selx.Execute()

fixed = sitk.ReadImage('fixed.nii.gz')
moving = sitk.ReadImage('moving.nii.gz')

try:
    register(fixed, moving)
except Exception as e:
    print e

# This time will fail with xout
try:
    register(fixed, moving)
except Exception as e:
    print e

If you want, I can send you the images also?

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

Yes, please do!

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

https://www.dropbox.com/s/bgq4mv9mmisgxl6/fixed.nii.gz?dl=0
https://www.dropbox.com/s/sn9fah3hkmrsfo6/moving.nii.gz?dl=0

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

Hi Jorrit

I have tested your script with your data and the problem seems to be solved with the new tip of the SimpleElastix branch (dde6134). Let me know if the problem persists.

from simpleelastix.

JorritPosthuma avatar JorritPosthuma commented on August 18, 2024

Ran it using 43167de (at the moment, latest develop) and the bug is resolved!

Sorry for the long wait!

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on August 18, 2024

No problem, glad the issue has been resolved!

from simpleelastix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.