Skip to content

Commit

Permalink
updates "Permutate image axes" tool
Browse files Browse the repository at this point in the history
  • Loading branch information
kostrykin committed Nov 1, 2023
1 parent 8b5105d commit bd82f46
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
22 changes: 12 additions & 10 deletions tools/permutate_axis/permutate_axis.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
import argparse
import sys
import warnings

import numpy as np
import skimage.io
import skimage.util
import skimage.util


def permutate_axis(input_image_path, output_image_path, axis, permutate):
images = []
raw_image = skimage.io.imread(input_image_path, plugin='tifffile')
for i in permutate:
# TODO generalise
# TODO generalise
if axis == 0:
a_slice = raw_image[i]
elif axis == 1:
a_slice = raw_image[:,i]
a_slice = raw_image[:, i]
elif axis == 2:
a_slice = raw_image[:,:,i]
a_slice = raw_image[:, :, i]
elif axis == 3:
a_slice = raw_image[:,:,:,i]
a_slice = raw_image[:, :, :, i]
elif axis == 4:
a_slice = raw_image[:,:,:,:,i]
a_slice = raw_image[:, :, :, :, i]
images.append(np.expand_dims(a_slice, axis))

res = np.concatenate(images, axis)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
res = skimage.util.img_as_uint(res) #Attention: precision loss
skimage.io.imsave(output_image_path, res, plugin='tifffile')
warnings.simplefilter("ignore")
res = skimage.util.img_as_uint(res) # Attention: precision loss
skimage.io.imsave(output_image_path, res, plugin='tifffile')


if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down
10 changes: 8 additions & 2 deletions tools/permutate_axis/permutate_axis.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<tool id="ip_permutate_axis" name="Permutate image" version="0.2">
<description>along an axis</description>
<tool id="ip_permutate_axis" name="Permutate image axes" version="0.2-2">
<description></description>
<edam_operations>
<edam_operation>operation_3443</edam_operation>
</edam_operations>
<xrefs>
<xref type="bio.tools">galaxy_image_analysis</xref>
</xrefs>
<requirements>
<requirement type="package" version="0.14.2">scikit-image</requirement>
<requirement type="package" version="1.15.4">numpy</requirement>
Expand Down

0 comments on commit bd82f46

Please sign in to comment.