SimpleElastix 3D rigid registration fails to find same image - elastix-itk

I've been trying to get a basic registration working with SimpleElastix for a while now, but I'm not able to make it work at all, regardless of the settings used. Note that I'm trying to compare SimpleElastix to other methods, so using another library is not an option.
Here's the task I'm currently trying to do:
Take a 3D ultrasound scan of a fetus (img_scan)
Mask a part of the scan, and apply a rigid transform (img_structure)
Use SimpleElastix to register img_structure to img_scan.
Since img_structure was created from img_scan, I know for certain that there is an ideal solution to the registration. However, unless img_structure is extremely close to it's original position, SimpleElastix seems to barely do anything at all. For example, if I only translate img_structure in one axis, it works. But if I only rotate it 90 degrees, it fails although their centres are basically the same. To clarify, by fail I mean it returns a slightly transformed img_structure, but nowhere near the the actual solution]
This is the basic code I've started with:
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(fixed)
elastixImageFilter.SetMovingImage(moving)
elastixImageFilter.SetMovingMask(mask_moving)
elastixImageFilter.SetFixedMask(mask_fixed)
elastixImageFilter.SetParameterMap(sitk.GetDefaultParameterMap("rigid"))
elastixImageFilter.Execute()
Things I have tried:
With/without masks (or a combination)
Different MaximumStepLength
Different ImageSampler
Affine instead of rigid
Different Optimizers
What could I be missing?

Related

D* / D* Lite query (dynamic pathfinding algorithms)

I'm writing a paper comparing D*, D* Lite and LPA* and how useful they are in navigating an agent across a dynamic environment.
If anyone has any info that would be helpful for this please leave below.
Specifically, can anyone explain in simple terms why D* and D* lite traverse from goal to start rather than start to goal like LPA*? I understand the g value would then be the distance from the goal but confused as to what benefits this has.
Thanks in advance.
When you search outwards from the start state, all of the outward paths also give you routes back to the start, making it easy to get back there. Then, when you get to the goal, you have one path to the goal, but many paths from other states back to the start.
If the world isn't changing it doesn't matter whether you search backwards or forwards (or bidirectionally), in the end you have a path that you can use.
But, if the world changes and you lose your one path to the goal from a forward search, it can be hard to re-connect to that single path. If instead you search outwards from the goal, you still have many paths back to the goal. If the world changes, you can then search to reconnect the invalidated states back to any path that leads to the goal (of which there are many). Although it may not be optimal, it may only require a small and simple repair.

Disassemble surfaces in CATIA using VBA

Is there a way to disassemble a surface in domains in CATIA through VBA, maintaining the dependencies between the initial surface and the separated domains?
I can suggest 2 options, I have already employed both of them in my works in a similar way. None of them will of course be guaranteed to update after input changes, but associativity with existing domains will exist.
Option 1:
Pick a random face in automation using Search (within topology option in the query string. To get to the right query string, first try it using manual searches with Include Topology option active).
Create two Extract with Point continuity based on this face: one will be the first domain you're looking for, the second will be in Complementary mode and the input for the next step
Repeat recursively from step 1 until all domains are extracted. Last complementary extract will probably raise an error (manage it with On Error Statement)
Option 2:
Disassemble in domains getting dumb surfaces, store them.
Create a point on surface on each of them
Create many Near, always on the same input surface, using each of the points obtained before.
If you don't like keeping relationships with dumb surfaces, insert this step after step 2: read point's coordinates using GetCoordinates method, then create another point by coordinates and use that into the Near. Then delete all dumb surfs and points created on them.
Regards

How to quickly analyse the impact of a program change?

Lately I need to do an impact analysis on changing a DB column definition of a widely used table (like PRODUCT, USER, etc). I find it is a very time consuming, boring and difficult task. I would like to ask if there is any known methodology to do so?
The question also apply to changes on application, file system, search engine, etc. At first, I thought this kind of functional relationship should be pre-documented or some how keep tracked, but then I realize that everything can have changes, it would be impossible to do so.
I don't even know what should be tagged to this question, please help.
Sorry for my poor English.
Sure. One can technically at least know what code touches the DB column (reads or writes it), by determining program slices.
Methodology: Find all SQL code elements in your sources. Determine which ones touch the column in question. (Careful: SELECT ALL may touch your column, so you need to know the schema). Determine which variables read or write that column. Follow those variables wherever they go, and determine the code and variables they affect; follow all those variables too. (This amounts to computing a forward slice). Likewise, find the sources of the variables used to fill the column; follow them back to their code and sources, and follow those variables too. (This amounts to computing a backward slice).
All the elements of the slice are potentially affecting/affected by a change. There may be conditions in the slice-selected code that are clearly outside the conditions expected by your new use case, and you can eliminate that code from consideration. Everything else in the slices you may have inspect/modify to make your change.
Now, your change may affect some other code (e.g., a new place to use the DB column, or combine the value from the DB column with some other value). You'll want to inspect up and downstream slices on the code you change too.
You can apply this process for any change you might make to the code base, not just DB columns.
Manually this is not easy to do in a big code base, and it certainly isn't quick. There is some automation to do for C and C++ code, but not much for other languages.
You can get a bad approximation by running test cases that involve you desired variable or action, and inspecting the test coverage. (Your approximation gets better if you run test cases you are sure does NOT cover your desired variable or action, and eliminating all the code it covers).
Eventually this task cannot be automated or reduced to an algorithm, otherwise there would be a tool to preview refactored changes. The better you wrote code in the beginning, the easier the task.
Let me explain how to reach the answer: isolation is the key. Mapping everything to object properties can help you automate your review.
I can give you an example. If you can manage to map your specific case to the below, it will save your life.
The OR/M change pattern
Like Hibernate or Entity Framework...
A change to a database column may be simply previewed by analysing what code uses a certain object's property. Since all DB columns are mapped to object properties, and assuming no code uses pure SQL, you are good to go for your estimations
This is a very simple pattern for change management.
In order to reduce a file system/network or data file issue to the above pattern you need other software patterns implemented. I mean, if you can reduce a complex scenario to a change in your objects' properties, you can leverage your IDE to detect the changes for you, including code that needs a slight modification to compile or needs to be rewritten at all.
If you want to manage a change in a remote service when you initially write your software, wrap that service in an interface. So you will only have to modify its implementation
If you want to manage a possible change in a data file format (e.g. length of field change in positional format, column reordering), write a service that maps that file to object (like using BeanIO parser)
If you want to manage a possible change in file system paths, design your application to use more runtime variables
If you want to manage a possible change in cryptography algorithms, wrap them in services (e.g. HashService, CryptoService, SignService)
If you do the above, your manual requirements review will be easier. Because the overall task is manual, but can be aided with automated tools. You can try to change the name of a class's property and see its side effects in the compiler
Worst case
Obviously if you need to change the name, type and length of a specific column in a database in a software with plain SQL hardcoded and shattered in multiple places around the code, and worse many tables present similar column namings, plus without project documentation (did I write worst case, right?) of a total of 10000+ classes, you have no other way than manually exploring your project, using find tools but not relying on them.
And if you don't have a test plan, which is the document from which you can hope to originate a software test suite, it will be time to make one.
Just adding my 2 cents. I'm assuming you're working in a production environment so there's got to be some form of unit tests, integration tests and system tests already written.
If yes, then a good way to validate your changes is to run all these tests again and create any new tests which might be necessary.
And to state the obvious, do not integrate your code changes into the main production code base without running these tests.
Yet again changes which worked fine in a test environment may not work in a production environment.
Have some form of source code configuration management system like Subversion, GitHub, CVS etc.
This enables you to roll back your changes

How to change node edge lines in Cytoscape.js?

I have a bunch of nodes on each side of a central node. I am trying to find a way to position the node lines so that they go to the right or left side of the nodes.
So for this:
http://jsbin.com/ipuxub/4/edit?js,output
I want the lines for the Jerry node to go to right side of Elaine, George, Kramer, etc.
While I don't think this is possible now:
Is there a way to force it, trick it or make it look better?
If it is changing the Cytoscape JS code, any suggestions to where I begin or look at or what would need to be changed?
Controlling edge control points more manually or adding support for node bend points are things we have planned to add in future, and I think either case would satisfy your use case.
However, we do not have the resources to do this in the short term: Both cases require our side to plan how those features would fit in with the model and visual style system (cy.js css).
In the short term, if you want to control where edges are drawn, you have to adjust the positions of the connected nodes -- because the edge positions are inferred between them. The first edge is straight between them, and for 2 or more beziers are used.
If moving node positions does not suffice for your usecase, the first steps would be for us to discuss and plan how this feature would work and how it would fit into the system: https://github.com/cytoscape/cytoscape.js/issues/359
Then if you're interested in implementing it, it would be a straightforward process. We could direct you to the relevant parts of the code that would need to be changed etc over a Google+ call.
Thanks -M

Building an Interface for User Generated Graphs

I've researched this issue and have not found anything to meet my needs. I am worried that perhaps I'm using the wrong terms.
I would like to build a website interface that allows users to select different variables and then have those variables dynamical or automatically graphed or charted. I need it to be able to handle 100+ variables (there could be limits to how many were charted at one time) and display the data on a bar graph, pie chart, or line graph based on the users preference.
What would I need to make this happen?
Sounds like you need to use either Flash and ActionScript or JavaScript and HTML5.
I've been looking to do something like this too actually.
Need a facility for parsing the data, and then working out scales/ratios and to represent the data in a coherent way, with labels. Then you need to scale the shapes your using according to the scale that the data is covering, and for the sizes to naturally be proportional.