Mercurial > repos > iuc > imagej2_bunwarpj_raw_transform
comparison jython_utils.py @ 0:64aacdf3171f draft
planemo upload commit 7195716d447effc5bc32154279de4b84369eccdb-dirty
| author | iuc |
|---|---|
| date | Fri, 19 Jun 2015 16:59:58 -0400 |
| parents | |
| children | 6f129c1ec6d1 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:64aacdf3171f |
|---|---|
| 1 import imagej2_base_utils | |
| 2 from ij import IJ | |
| 3 | |
| 4 def convert_before_saving_as_tiff( image_plus ): | |
| 5 # The bUnwarpJ plug-in produces TIFF image stacks consisting of 3 | |
| 6 # slices which can be viewed in ImageJ. The 3 slices are: 1) the | |
| 7 # registered image, 2) the target image and 3) the black/white warp | |
| 8 # image. When running bUnwarpJ from the command line (as these | |
| 9 # Galaxy wrappers do) the initial call to IJ.openImage() (to open the | |
| 10 # registered source and target images produced by bUnwarpJ) in the | |
| 11 # tool's jython_script.py returns an ImagePlus object with a single | |
| 12 # slice which is the "generally undesired" slice 3 discussed above. | |
| 13 # However, a call to IJ.saveAs() will convert the single-slice TIFF | |
| 14 # into a 3-slice TIFF image stack (as described above) if the selected | |
| 15 # format for saving is TIFF. Galaxy supports only single-layered | |
| 16 # images, so to work around this behavior, we have to convert the | |
| 17 # image to something other than TIFF so that slices are eliminated. | |
| 18 # We can then convert back to TIFF for saving. There might be a way | |
| 19 # to do this without converting twice, but I spent a lot of time looking | |
| 20 # and I have yet to discover it. | |
| 21 tmp_dir = imagej2_base_utils.get_temp_dir() | |
| 22 tmp_out_png_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, 'png' ) | |
| 23 IJ.saveAs( image_plus, 'png', tmp_out_png_path ) | |
| 24 return IJ.openImage( tmp_out_png_path ) |
