Write uncompressed metimage with Slicer

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Write uncompressed metimage with Slicer

bluisier
Dear Slicer users,

Four our projects, we are using uncompressed metaimage (.mhd files). In
the future, we will most likely use Slicer to do manual tasks like
cropping or registrating images. My question is the following: As Slicer
most likely use the vtk.metaimagewriter function to write out .mhd
files, what would be the best strategy for me to set the Setcompression
function to off? Is there a way to make Slicer simply write the .mhd
files uncompressed? I was also thinking to write a python plugin where I
could just write out an uncompressed metaimage. But it would be really
great if I could find a way to just write out all the .mhd files from
Slicer in an uncompressed way...

Thanks a lot

Benoit

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: Write uncompressed metimage with Slicer

Julien Finet
Hi Benoit,

It's a feature missing in Slicer4:

A temporary solution is to write some code in the python console before opening the Save Data dialog.
Indeed, if you look at vtkMRMLVolumeArchetypeStorageNode::WriteData(), it passes the property UseCompression to the file writer.
This property is set in a mother class vtkMRMLStorageNode and it's true(1) by default. You need to set the property to false in your case.
What you can do is:
* check from the data module the ID of the vtkMRMLVolumeArchetypeStorageNode node of your volume (probably "vtkMRMLVolumeArchetypeStorageNode1", "vtkMRMLVolumeArchetypeStorageNode2"...)
* open your python console. and type the following
     node = slicer.mrmlScene.GetNodeByID('vtkMRMLVolumeArchetypeStorageNode1')
     node.UseCompression = 0
Then you can save the data from the Save Data dialog, it will be uncompressed.

This can be inconvenient if you have plenty of files to save. I'm currently redesigning the Save Data dialog, so I might add a mechanism to simplify adding options such as compression when saving data.

Julien.

On Sat, May 26, 2012 at 7:06 AM, Benoit Luisier <[hidden email]> wrote:
Dear Slicer users,

Four our projects, we are using uncompressed metaimage (.mhd files). In
the future, we will most likely use Slicer to do manual tasks like
cropping or registrating images. My question is the following: As Slicer
most likely use the vtk.metaimagewriter function to write out .mhd
files, what would be the best strategy for me to set the Setcompression
function to off? Is there a way to make Slicer simply write the .mhd
files uncompressed? I was also thinking to write a python plugin where I
could just write out an uncompressed metaimage. But it would be really
great if I could find a way to just write out all the .mhd files from
Slicer in an uncompressed way...

Thanks a lot

Benoit

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: Write uncompressed metimage with Slicer

Andras Lasso

The uncompressed save option would be convenient, because several frequently used image analysis applications cannot read compressed metaimage files. E.g., ParaView (actually any software that uses VTK’s vtkMetaImageReader) and ImageJ’s metaimagereader plugin, or any other implementation that does not have access to zlib can only read uncompressed metaimage files.

 

Andras

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Julien Finet
Sent: May 26, 2012 8:48 AM
To: Benoit Luisier
Cc: [hidden email]
Subject: Re: [slicer-users] Write uncompressed metimage with Slicer

 

Hi Benoit,

 

It's a feature missing in Slicer4:

 

A temporary solution is to write some code in the python console before opening the Save Data dialog.

Indeed, if you look at vtkMRMLVolumeArchetypeStorageNode::WriteData(), it passes the property UseCompression to the file writer.

This property is set in a mother class vtkMRMLStorageNode and it's true(1) by default. You need to set the property to false in your case.

What you can do is:

* check from the data module the ID of the vtkMRMLVolumeArchetypeStorageNode node of your volume (probably "vtkMRMLVolumeArchetypeStorageNode1", "vtkMRMLVolumeArchetypeStorageNode2"...)

* open your python console. and type the following

     node = slicer.mrmlScene.GetNodeByID('vtkMRMLVolumeArchetypeStorageNode1')

     node.UseCompression = 0

Then you can save the data from the Save Data dialog, it will be uncompressed.

 

This can be inconvenient if you have plenty of files to save. I'm currently redesigning the Save Data dialog, so I might add a mechanism to simplify adding options such as compression when saving data.

 

Julien.

 

On Sat, May 26, 2012 at 7:06 AM, Benoit Luisier <[hidden email]> wrote:

Dear Slicer users,

Four our projects, we are using uncompressed metaimage (.mhd files). In
the future, we will most likely use Slicer to do manual tasks like
cropping or registrating images. My question is the following: As Slicer
most likely use the vtk.metaimagewriter function to write out .mhd
files, what would be the best strategy for me to set the Setcompression
function to off? Is there a way to make Slicer simply write the .mhd
files uncompressed? I was also thinking to write a python plugin where I
could just write out an uncompressed metaimage. But it would be really
great if I could find a way to just write out all the .mhd files from
Slicer in an uncompressed way...

Thanks a lot

Benoit

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject

 


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: Write uncompressed metimage with Slicer

Steve Pieper
As a side note on compression, Demian and I did some profiling of CLI modules and found that a huge amount of the processing time was being spent compressing the images (the long "Scheduling" step you see when running, in particular, diffusion CLIs).  Turning off compression sped this up tremendously in our tests so it will be the default from here on out on the CLI interface. 

I mention this because giving users the option to turn of compression for volumes in the save dialog should not only improve interoperability but also improve scene load/save performance (obviously at the expense of disk space).

-Steve

On Sat, May 26, 2012 at 9:11 AM, Andras Lasso <[hidden email]> wrote:

The uncompressed save option would be convenient, because several frequently used image analysis applications cannot read compressed metaimage files. E.g., ParaView (actually any software that uses VTK’s vtkMetaImageReader) and ImageJ’s metaimagereader plugin, or any other implementation that does not have access to zlib can only read uncompressed metaimage files.

 

Andras

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Julien Finet
Sent: May 26, 2012 8:48 AM
To: Benoit Luisier
Cc: [hidden email]
Subject: Re: [slicer-users] Write uncompressed metimage with Slicer

 

Hi Benoit,

 

It's a feature missing in Slicer4:

 

A temporary solution is to write some code in the python console before opening the Save Data dialog.

Indeed, if you look at vtkMRMLVolumeArchetypeStorageNode::WriteData(), it passes the property UseCompression to the file writer.

This property is set in a mother class vtkMRMLStorageNode and it's true(1) by default. You need to set the property to false in your case.

What you can do is:

* check from the data module the ID of the vtkMRMLVolumeArchetypeStorageNode node of your volume (probably "vtkMRMLVolumeArchetypeStorageNode1", "vtkMRMLVolumeArchetypeStorageNode2"...)

* open your python console. and type the following

     node = slicer.mrmlScene.GetNodeByID('vtkMRMLVolumeArchetypeStorageNode1')

     node.UseCompression = 0

Then you can save the data from the Save Data dialog, it will be uncompressed.

 

This can be inconvenient if you have plenty of files to save. I'm currently redesigning the Save Data dialog, so I might add a mechanism to simplify adding options such as compression when saving data.

 

Julien.

 

On Sat, May 26, 2012 at 7:06 AM, Benoit Luisier <[hidden email]> wrote:

Dear Slicer users,

Four our projects, we are using uncompressed metaimage (.mhd files). In
the future, we will most likely use Slicer to do manual tasks like
cropping or registrating images. My question is the following: As Slicer
most likely use the vtk.metaimagewriter function to write out .mhd
files, what would be the best strategy for me to set the Setcompression
function to off? Is there a way to make Slicer simply write the .mhd
files uncompressed? I was also thinking to write a python plugin where I
could just write out an uncompressed metaimage. But it would be really
great if I could find a way to just write out all the .mhd files from
Slicer in an uncompressed way...

Thanks a lot

Benoit

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject

 


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: Write uncompressed metimage with Slicer

bluisier
Hi guys,

Thanks for your fast answers... I'm happy to know that this issue will
be fixed soon and your temporary solution will be fine for me. Just one
issue:
When I type in the python console:
     node =
slicer.mrmlScene.GetNodeByID('vtkMRMLVolumeArchetypeStorageNode1')
     print node
I see that the UseCompression method is set to 1. But if I type then:
     node.UseCompression = 0
     print node
The UseCompression is still set to 1. if I type then:
     print node.UseCompression
it gives me 0. (strange... node.UseCompression is set to 0 but if I
print node it is still 1)
And of course if I save my file, it is still compressed...
I dont get it.I'm just not able to set this property to 0... Am I
missing smth???

Thks again

Benoit
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: Write uncompressed metimage with Slicer

bluisier
In reply to this post by Steve Pieper
Hi guys...

I just fixed my problem... instead of typing:
     node.UseCompression = 0
I should just type:
     node.SetUseCompression(0)

It sets the UseCompression property to 0 and allows me to save
uncompressed mhd's.

Thanks again
Best

Benoit
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject