Background Image Script?
 1-8  9-28  29-32

Previous
Next
 From:  bemfarmer
6162.9 
Did a search for "Multiplanar Reconstruction."

JIM costs about 10X to 20X the cost of MoI.
http://www.xinapse.com/Manual/index.html

It has a nice NON clinical use disclaimer.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.10 In reply to 6162.8 
Thanks Brian! I'm on my phone so replied inline.

Each image is a sequential slice, of the 3D object,
separated by an increment of ____ mm, which determines the layer of the traced
2d object. (The example is using the front frame, x,z.)
-Yes (although front frame might be X, Y depending on coordinate system used)

Each image slice is loaded with the same x,z (or x,y?) position and (non)rotation.
-Yes

The image is "below" created objects? (or with objects or above objects?)
-Yes, image should be below.

The transparency setting is ___?
-Standard user controllable would be best


A slice is loaded, and the user traces a 2D object on the new layer.
-Yes

The previous 2D objects, (layers), need to be hidden?
-This should be an option. Sometimes this is not desirable, sometimes it is (also in a perfect world sometimes the previous layer geometry would be copied and left on the new layer, but this should be optional)

The user can flip back and forth between 2d object layers, or background slices,
to glean 3D help for the 2D trace.
-Yes, although layers are easy enough to handle, but perhaps layer visibility could be optionally linked to BG frame selected?

...
- Brian
EDITED: 10 Sep 12:17 by BEMFARMER

 
 
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.11 In reply to 6162.9 
I haven't used Jim, I have used OsiriX to do some 3D reconstruction in the past It is a fantastic free and open-source Dicom viewer, but a terribly blunt tool for this kind of reconstruction.

The nice thing about MoI being a front-end to reconstruction is having the full power of a fast, efficient modeller instead of a basic 2D spline interface. The trick is keeping the units, etc, but that seems trivial!

It also occurred to me that the same general concept could be used to import, view and edit slices of gcode generated for 3d printing, although tools already exist for that... it might be useful to overlay gcode with original models.I should stop before I draw us off-topic :)

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.12 In reply to 6162.7 
Hi FDP, that's really a quite complex script (or is it multiple different scripts) that you're talking about there, every sequence like "ask the user to do this or that" actually take a fair amount of time to write.

I can help you get started on it, you may need to build up the more complex parts of the script yourself.

Let's try building it up in some stages, how about an initial stage where it just increments an existing file and make sure that part is working ok for you first before trying to move on to more functionality.

I'll see if I can write some initial starting point for you to test with.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.13 In reply to 6162.11 
Hi FDP, I've attached an initial starting point - copy the attached IncrementImage.js file into the \commands folder inside of MoI's main installation folder. That will then make a new command named IncrementImage available. To trigger the command set up a keyboard shortcut for the command part of the shortcut key put in: IncrementImage (just plain IncrementImage, no "script:" prefix and no .js extension).

The command expects for there to be one already existing background image in the file. It will get the filename of that background image and split the name into pieces, increment the numeric piece and then set the new filename onto the image. Internally that causes a reload of the image and the image should update.

Note that currently it is assumed that the filenames have 5 numeric digits in them before the file extension part, and it's also assumed that all the images of the set have the same aspect ratio. The 3D-space image size stays the same during this reload and if the new images does not have the same pixel dimensions as the old one it will still be stretched to fit in the same area as the old one anyway.

One other note - when you're working on editing this command there is a setting that you should change first in moi.ini to prevent command files from being cached. Go to Options > General and push the "Edit .ini file" button. Then in the [UI] section of the .ini file set:
DisableFileCaching=y

By default MoI internally caches any command file that it reads off disk, which is annoying when you're making changes to them since it means you have to exit MoI and restart it to get the new script to be loaded. But if you set DisableFileCaching=y you can keep MoI open and it will reload the command file each time the command is launched instead.

- Michael

EDITED: 10 Sep 2013 by MICHAEL GIBSON

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6162.14 In reply to 6162.13 
Tried the script with the chest samples, and also with the following brain scans, relabeled 00001, 00002, etc.
http://en.wikipedia.org/wiki/File:Computed_tomography_of_human_brain_-_large.png

The script works!
When the script gets to the end, the highest number, it seems to keep reloading the last image, with label number incremented
higher each time.

- Brian

When I misspelled Brain00006 as Brian00006, it reloaded Brain00005 as 00006, and on the next load, loaded 00007. :-) (OK)

EDITED: 10 Sep 2013 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.15 In reply to 6162.14 
Hi Brian,

> When the script gets to the end, the highest number, it seems to keep reloading
> the last image, with label number incremented
> higher each time.

Yeah when you get to a file that does not exist, the reload fails and the last valid image still stays as the one displayed.

Right now there's not a very convenient way for a script to detect if a file exists or not, so for now you would just want to pay attention to not go past the last one, or modify the script to have the last number set in the script so that it can look at that to know if it's at the end one or not.

I'll add in a method to the script layer for the next v3 beta to make it easier for a script to know if a given file exists or not.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.16 In reply to 6162.15 
Thanks Michael!
I'll give this a try tonight! Can't thank you enough!

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.17 In reply to 6162.16 
For coding, I'm sorry to ask this basic question (didn't find anything with Googling the site), is there a js console available in MoI?

Thanks,
FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.18 In reply to 6162.17 
Hi FDP,

> For coding, I'm sorry to ask this basic question (didn't find anything with Googling the site),
> is there a js console available in MoI?

Sorry, no there isn't anything as sophisticated as that available yet, you just have to edit the file in a separate text editor.

I'd like to make a much more sophisticated scripting environment in the future but it will be quite a while before I'm able to do that, there is a lot of work involved.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.19 In reply to 6162.18 
Thanks Michael!
I got the script to work! Making a decrement version was super easy (just changed line 63 to "--num;").

Now I just have to figure out how to take a modifier for the command (e.g. fork at --num or ++num).

Is there a way to select objects by name and then change that name? E.g. objectpicker(object.objectname == "Unnamed")?

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.20 In reply to 6162.19 
Hi FDP,

> Is there a way to select objects by name and then change that name?
> E.g. objectpicker(object.objectname == "Unnamed")?

You can get an object list of all current objects by doing moi.geometryDatabase.getObjects(); then if you want to only target "unnamed" objects look for objects that have a .name property that returns an empty string which is represented in JavaScript by just 2 quotes with nothing inside of them.

Here's an example:

code:
function SetObjectNames( newname )
{
	// Set any unnamed objects to have the given name.

	var objects = moi.geometryDatabase.getObjects();
	
	for ( var i = 0; i < objects.length; ++i )
	{
		var obj = objects.item(i);
		
		// An "unnamed" object will have an empty string as its name property.
		if ( obj.name == '' )
			obj.name = newname;	
	}
}


So a call to this function like: SetObjectNames( 'flimflam' ); will set any unnamed objects to have the name 'flimflam', but would not change objects that already have a name.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.21 In reply to 6162.19 
Hi FDP,

> Now I just have to figure out how to take a modifier for the command (e.g. fork at --num or ++num).

It is possible to pass parameters to a command so that you can have 2 different keyboard shortcuts each of which call the same command but with slightly different behavior.

The Nudge plug-ins do this so they're the best ones to look at for an example:
http://kyticka.webzdarma.cz/3d/moi/#Nudge

You basically put the parameter as a second word in the keyboard shortcut, with a space after the command name, like:
IncrementImage backward

Then inside the command script file, use moi.command.getCommandLineParams() to access those parameters.

Something like this example from the Nudge command:

code:
	var params = moi.command.getCommandLineParams();
	
	if ( params.search( /left/i ) != -1 )
	{
		// The parameters contain the word "left" in it.
		dist = -dist;
	}


- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.22 In reply to 6162.21 
Thanks Michael!

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.23 In reply to 6162.20 
Hi Michael,

I have dropped the function you gave into the initial script and it did exactly what I had hoped!

I'll try to expand this to match the rest of what I had been going for in the pseudocode example over the next few days. I was also thinking of using the system clock script as a basis for a current frame# display in the bottom right hand corner of the window.

Our of interest, is there any reason why there isn't more of a push to have users add buttons to the GUI for running custom scripts?

I attached the script with the added function to rename curves to match image bg numbers in case anyone else wants to use it.

Regards,
FDP
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6162.24 In reply to 6162.23 
Hi FDP, I'm glad that naming function worked for you!

> Our of interest, is there any reason why there isn't more of a push to have users add
> buttons to the GUI for running custom scripts?

It's on my "todo" list but so are a zillion other things. Right now I'm still focused on more core functionality, things like custom scripts are definitely useful but they're used by only a small number of advanced users, while core functionality is used by a wide range of users... So that factors into the urgency of which features get attention.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.25 In reply to 6162.24 
I definitely understand. You are one person - MoI is fantastic and your support on this forum is really top notch, so I'm certainly not trying to complain!

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.26 In reply to 6162.25 
I thought this might be helpful to others - the method I use for getting image sequences out of stacks that are in video format is by using ffmpeg. On Windows the command line parameters are slightly different than linux/OsX, the following example will work if all you want are low-quality jpegs:

ffmpeg -i "Input_Filename.mp4" -f image2 Output_Filename%%5d.jpg

The "%%5d" part is telling ffmpeg to pad the output frame counter to 5 digits, which will make the results compatible with Michael's "IncrementImage" script.

You can use different filetypes, e.g. .mov or .avi for the input file type and .png, etc for the output file type.

Windows builds of ffmpeg can be found here: http://ffmpeg.zeranoe.com/builds/

The precompiled ffmpeg application is found in the bin folder

Incidentally on Linux/OsX the following should be an equivalent command:

ffmpeg -i "Input_Filename.mp4" -f image2 Output_Filename%5d.jpg

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6162.27 In reply to 6162.26 
Thank you FDP.

Is there a good source for CT scan image video (free)?

I see that they use video at:
http://arc-team-open-research.blogspot.com/2012/09/converting-video-of-computed-tomography.html
http://www.oucom.ohiou.edu/dbms-witmer/3D-Visualization.htm

I spent a little time looking at Invesalius, 3DSlicer, and RadiAnt, which use "DICOM."
There are a couple of programs called "img2dcm," code anyway, to convert PNG and/or JPEG to DICOM,
but a person would have to be a software expert to use it.(?) I'll have to try the Python line.

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  FDP
6162.28 In reply to 6162.27 
Hi Brian,
DICOM is pretty much the industry standard, and usually consists of a stack of scan images (float) with metadata.

For cross platform, take a look at ImageJ, it's free & powerful with tons of plugins.

On OsX the best program is OsiriX, which is outstanding for volumetric data processing in general.

If you Google " CT stack " or "DICOM data" you should find some examples pretty easily. YouTube also has some examples.

The example I used was from the Wikipedia "Computed Tomography" page :)

-FDP
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
Show messages:  1-8  9-28  29-32