Giter VIP home page Giter VIP logo

microfilm's Introduction

Binder build PyPI - License PyPI - Python Version PyPI PyPI - Status

microfilm

This package is a collection of tools to display and analyze 2D and 2D time-lapse microscopy images. In particular it makes it straightforward to create figures containing multi-channel images represented in a composite color mode as done in the popular image processing software Fiji. It also allows to easily complete such figures with standard annotations like labels and scale bars. In case of time-lapse data, the figures are turned into animations which can be interactively browsed from a Jupyter notebook, saved in standard movie formats (mp4, gif etc.) and completed with time counters. Finally, figures and animations can easily be combined into larger panels. These main functionalities are provided by the microfilm.microplot and microfilm.microanim modules.

Following the model of seaborn, microfilm is entirely based on Matplotlib and tries to provide good defaults to produce good microcopy figures out-of-the-box. It however also offers complete access to the Matplotlib structures like axis and figures underlying the microfilm objects, allowing thus for the creation of arbitrarily complex plots.

Installation

You can install this package directly with pip using:

pip install microfilm

To get the latest stage of the package with yet unreleased features use:

pip install git+https://github.com/guiwitz/microfilm.git

To test the package via the Jupyter interface and the notebooks available here you can create a conda environment using the environment.yml file:

conda env create -f environment.yml

Optional installs

If you want to use the dataset submodule (see below in Additional functionalities) and need to handle multipage tiff files or nd2 files, use:

pip install "microfilm[multipage]"

or

pip install "microfilm[nd2]"

If you plan to not just use simple plotting but want to create animations, you need to install:

pip install "microfilm[animation]"

To install all options use:

pip install "microfilm[all]"

Simple plot

It is straightforward to create a ready-to-use plot of a multi-channel image dataset. In the following code snippet, we load a Numpy array of a multi-channel time-lapse dataset with shape CTXY (three channels). The figure below showing the time-point t=10 is generated in a single command with a few options and saved as a png:

import numpy as np
import skimage.io
from microfilm.microplot import microshow

image = skimage.io.imread('../demodata/coli_nucl_ori_ter.tif')
time = 10

microim = microshow(
    images=image[:, time, :, :], fig_scaling=5,
    cmaps=['pure_blue','pure_red', 'pure_green'],
    unit='um', scalebar_size_in_units=3, scalebar_unit_per_pix=0.065, scalebar_font_size=20,
    label_text='A', label_font_size=0.04)

microim.savefig('../illustrations/composite.png', bbox_inches = 'tight', pad_inches = 0, dpi=600)

image

Animation

It is then easy to extend a simple figure into an animation as both objects take the same options. Additionally, a time-stamp can be added to the animation. This code generates the movie visible below:

import numpy as np
import skimage.io
from microfilm.microanim import Microanim

image = skimage.io.imread('../demodata/coli_nucl_ori_ter.tif')

microanim = Microanim(data=image, cmaps=['pure_blue','pure_red', 'pure_green'], fig_scaling=5,
                      unit='um', scalebar_size_in_units=3, scalebar_unit_per_pix=0.065,
                      scalebar_thickness=0.02, scalebar_font_size=20)

microanim.add_label('A', label_font_size=30)
microanim.add_time_stamp('T', 10, location='lower left', timestamp_size=20)

microanim.save_movie('../illustrations/composite_movie.gif', fps=15)

image

Panels

Both simple figures and animations can be combined into larger panels via the microplot.Micropanel and microanim.Microanimpanel objects. For example we can first create two figures microim1 and microim2 and then combine them into micropanel:

from microfilm import microplot
import skimage.io

image = skimage.io.imread('../demodata/coli_nucl_ori_ter.tif')

microim1 = microplot.microshow(images=[image[0, 10, :, :], image[1, 10, :, :]],
                               cmaps=['Greys', 'pure_magenta'], flip_map=[False, False],
                               label_text='A', label_color='black')
microim2 = microplot.microshow(images=[image[0, 10, :, :], image[2, 10, :, :]],
                               cmaps=['Greys', 'pure_cyan'], flip_map=[False, False],
                               label_text='B', label_color='black')

micropanel = microplot.Micropanel(rows=1, cols=2, figsize=[4,3])

micropanel.add_element(pos=[0,0], microim=microim1)
micropanel.add_element(pos=[0,1], microim=microim2)

micropanel.savefig('../illustrations/panel.png', bbox_inches = 'tight', pad_inches = 0, dpi=600)

image

And similarly for animations:

from microfilm import microanim
import skimage.io

image = skimage.io.imread('../demodata/coli_nucl_ori_ter.tif')

microanim1 = microanim.Microanim(data=image[[0,1],::], cmaps=['Greys', 'pure_magenta'],
                                 flip_map=[False, False], label_text='A', label_color='black')
microanim2 = microanim.Microanim(data=image[[0,2],::], cmaps=['Greys', 'pure_cyan'],
                                 flip_map=[False, False], label_text='B', label_color='black')

microanim1.add_time_stamp(unit='T', unit_per_frame='3', location='lower-right', timestamp_color='black')

animpanel = microanim.Microanimpanel(rows=1, cols=2, figsize=[4,3])
animpanel.add_element(pos=[0,0], microanim=microanim1)
animpanel.add_element(pos=[0,1], microanim=microanim2)

animpanel.save_movie('../illustrations/panel.gif')

image

Additional functionalities

In addition to these main plotting capabilities, the packages also offers:

  • microfilm.colorify: a series of utility functions used by the main functions to create the composite color images. It contains functions to create colormaps, to turn 2D arrays into 3D-RGB arrays with appropriate colormaps etc.
  • microfilm.dataset: a module offering a simple common data structure to handle multi-channel time-lapse data from multipage tiffs, series of tiff files, Nikon ND2 files, H5 and Numpy arrays. Requirement to use this module are at the moment very constrained (e.g. dimension order of Numpy arrays, name of H5 content etc.) but might evolve in the future.

Authors

This package has been created by Guillaume Witz, Microscopy Imaging Center and Science IT Support, University of Bern.

microfilm's People

Contributors

guiwitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

microfilm's Issues

Documentation Request

Hi, thanks for writing microfilm - it's been incredibly helpful for quickly overlaying large numbers of multichannel images. One suggestion I would like to recommend is to make the microshow() function arguments a bit clearer in the documentation. I only just realized I can pass in my own axes object using the ax argument making for easy integration with matplotlib. If I knew this I would have been using it sooner! Cheers.

Function: https://github.com/guiwitz/microfilm/blob/c0666e19b77db66b0af3a4d3759baaf19243b9db/microfilm/microplot.py#L14C1-L24C7

Color-blind friendly default color maps

Hi @guiwitz ,

I just started playing with microfilm and so far, I love it. I'd just have a minor suggestion: The default color maps (red, green, blue) pretty much fit to what people know from ImageJ, which is cool. Anyway, in image analysis courses we tell people to not use the default LUTs in ImageJ, because these are not color-blind friendly. Hence, one could think of using matplotlib-like default color maps using blue-orange-green-magenta. Or, to remain similar to ImageJ, just replace red with magenta and blue with cyan.

I'm just thinking in writing. Feel free to ignore this suggestion.

Best,
Robert

Passing a matplotlib axis object to Microanim seems to have no effect

Dear guiwitz,

I am having some troubles understanding the behavior of passing a Matplotlib axis object to the Microanim function. In particular, when executing the following code it appears to me that the Microanim function has no effect on the axis object.

import numpy as np
import skimage.io
import matplotlib.pyplot as plt 
from microfilm.microanim import Microanim

image = skimage.io.imread('videos/coli_nucl_ori_ter.tif')
# image = skimage.io.imread('videos/res.tiff')
# image = image.transpose([1, 0, 2, 3])
# image = image[:1] # only one channel

fig, ax = plt.subplots()
microanim = Microanim(data=image, cmaps=['pure_blue','pure_red', 'pure_green'], fig_scaling=5,
                      unit='um', scalebar_size_in_units=3, scalebar_unit_per_pix=0.065,
                      scalebar_thickness=0.02, scalebar_font_size=20, ax=ax)

microanim.add_label('A', label_font_size=30)
microanim.add_time_stamp('T', 10, location='lower left', timestamp_size=20)

microanim.save_movie('composite_movie.gif', fps=15)
plt.show()                                                                                                                                                                                                                   

In any case, thanks again for this nice package, which is really useful to me.
Best,
Giacomo

Image appear double with panel

When adding images to a panel without specifying the relevant axis in the subplot, the image is displayed both in the panel and as a standalone. In such cases, the relevant axis, anyway specified in the pos option, should be used when creating the subplot to avoid double-plotting.

Issue with animations / example notebook

Hi @guiwitz ,

I'm continuing to explore microfilm and got stuck creating animations, I'm afraid recent changes broke the example in this notebook.

When calling this cell:

anim = Microanim(data=image, cmaps=['pure_blue','pure_red', 'pure_green'])
anim.ui

I receive this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [9], in <module>
----> 1 anim = Microanim(data=image, cmaps=['pure_blue','pure_red', 'pure_green'])
      2 anim.ui

File c:\structure\code\microfilm\microfilm\microanim.py:48, in Microanim.__init__(self, data, channels, cmaps, flip_map, rescale_type, limits, num_colors, proj_type, alpha, volume_proj, channel_names, channel_label_show, channel_label_type, channel_label_size, scalebar_thickness, scalebar_unit_per_pix, scalebar_size_in_units, unit, scalebar_location, scalebar_color, scalebar_font_size, scalebar_kwargs, scalebar_font_properties, ax, fig_scaling, dpi, label_text, label_location, label_color, label_font_size, label_kwargs, cmap_objects, show_colorbar, show_plot)
     46     target_dim=5 if (volume_proj is not None) else 3
     47     if data.ndim != target_dim:
---> 48         raise ValueError(f"The array needs {target_dim} dimensions, yours has {data.ndim}")
     49     data = Nparray(nparray=data)
     51 self.data = data

ValueError: The array needs 3 dimensions, yours has 4

And just a bit more context: I'm trying to turn a single-channel video (in dimension order TYX) into an animation... The error above however comes when running the unmodified notebook that uses a CTYX dataset...

Thanks!

Best,
Robert

Saving a microanimation

Description:
If the microanimation is saved in any format other than .gif I get the complaint even when no fps keyword is given:
TypeError: write() got an unexpected keyword argument 'fps'

used code that works fine with a .gif

time = 1000
image405_movie = np.array([image405[1]]*image640.shape[0])
image488_movie = np.array([image488[1]]*image640.shape[0])
fake_multichannel_movie = np.array((image405_movie[:time,:,:], image640[:time,:,:], image488_movie[:time,:,:]))
microanim = Microanim(data=fake_multichannel_movie, cmaps=['pure_blue','pure_red', 'pure_green'], fig_scaling=5,
unit='um', scalebar_size_in_units=3, scalebar_unit_per_pix=0.065,
scalebar_thickness=0.02, scalebar_font_size=20)

microanim.add_label('A', label_font_size=30)
microanim.add_time_stamp('T', 10, location='lower left', timestamp_size=20)

microanim.save_movie(os.path.join(outfolder, os.path.split(file)[1][:-4] + '_composit.avi'))


Full output:


TypeError Traceback (most recent call last)
Cell In[4], line 12
9 microanim.add_label('A', label_font_size=30)
10 microanim.add_time_stamp('T', 10, location='lower left', timestamp_size=20)
---> 12 microanim.save_movie(os.path.join(outfolder, os.path.split(file)[1][:-4] + '_composit.avi'))

File ~\Anaconda3\envs\image_anal\lib\site-packages\microfilm\microanim.py:207, in Microanim.save_movie(self, movie_name, fps, quality, format)
206 def save_movie(self, movie_name, fps=20, quality=5, format=None):
--> 207 save_movie(self, movie_name, fps=fps, quality=quality, format=format)

File ~\Anaconda3\envs\image_anal\lib\site-packages\microfilm\microanim.py:458, in save_movie(anim_object, movie_name, fps, quality, format)
456 w,h = map(int, anim_object.fig.canvas.renderer.get_canvas_width_height())
457 buf.shape = (h, w, 3)
--> 458 writer.append_data(buf)
460 writer.close()

File ~\Anaconda3\envs\image_anal\lib\site-packages\imageio\v2.py:226, in LegacyWriter.append_data(self, im, meta)
214 warnings.warn(
215 "V3 Plugins currently don't have a uniform way to"
216 " write metadata, so any metadata is ignored."
217 )
219 # total_meta = dict()
220 # if meta is None:
221 # meta = {}
222 # if hasattr(im, "meta") and isinstance(im.meta, dict):
223 # total_meta.update(im.meta)
224 # total_meta.update(meta)
--> 226 return self.instance.write(im, **self.write_args)

File ~\Anaconda3\envs\image_anal\lib\site-packages\imageio\plugins\tifffile_v3.py:224, in TifffilePlugin.write(self, ndimage, is_batch, **kwargs)
221 ndimage = np.asarray(ndimage)[None, :]
223 for image in ndimage:
--> 224 self._fh.write(image, **kwargs)
226 if self._request._uri_type == URI_BYTES:
227 self._fh.close()

TypeError: write() got an unexpected keyword argument 'fps'

Scalebar does not scale

Hallo,
This is essentially the first time I post an issue on github, so I already apologize in case this is not the right format.
I am experiencing some trouble with the scale bar. Essentially, for me, a convenient way of zooming into the image, especially when I already plotted other markers, is the following:

import skimage.io
from microfilm.microplot import microshow
import matplotlib.pyplot as plt


image = skimage.io.imread('coli_nucl_ori_ter.tif')
time = 10

fig, ax = plt.subplots()
# zooming into the first 10 pixel of the image
plt.xlim((0, 10))
plt.ylim((0, 10))
microim = microshow(images=image[:, time, :, :], fig_scaling=5,
                 cmaps=['pure_blue','pure_red', 'pure_green'],
                 unit='um', scalebar_size_in_units=3, scalebar_unit_per_pix=0.065, scalebar_text_centered=True, scalebar_font_size=0.04,label_text='A', label_font_size=0.04, ax=ax)

plt.show()

What then happens it that the scale bar seems to scale correctly with the image, but then indicates incorrect distances. Naturally, I would prefer it to give a warning, the correct number or just disappear, but not to provide an incorrect number. Could this be technically possible? So far, I solved the issue, resorting to the matplotlib-scalebar package. Thanks in advance for any suggestions and also thanks for the great package in general :)

Color-bar (feature request)

Hi @guiwitz ,

would it be "easy" / possible to have a color-bar next to an image? I'm asking because some pyclesperanto-users like that feature and I'm considering to use microfilm more often in similar contexts. It's demonstrated excessively here:
https://haesleinhuepf.github.io/BioImageAnalysisNotebooks/60_data_visualization/parametric_maps.html

It's a very simple implementation in pyclesperanto:
https://github.com/clEsperanto/pyclesperanto_prototype/blob/master/pyclesperanto_prototype/_tier9/_imshow.py#L41

Related discussion:

It might be challenging though with multi-channel images...

Looking forward to hear what you think!

Thanks!
Robert

Specifying multiple contrast limits for multiple images

Hi @guiwitz ,

this is a kind of follow-up bug report for #10 as I'm using very similar code. I'd like to specify contrast limits for multiple images/channels, and receive an error. This is the code:

from skimage.data import cells3d
from microfilm.microplot import microshow
from skimage.filters import gaussian

data = cells3d()
membrane_image = data[30,1]

blurred = gaussian(membrane_image, sigma=5)

microshow([membrane_image, blurred], limits=[
          np.percentile(membrane_image, [1,99]),
          np.percentile(blurred, [1,99])
        ])

And this is the error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [11], in <module>
      6 membrane_image = data[30,1]
      8 blurred = gaussian(membrane_image, sigma=5)
---> 10 microshow([membrane_image, blurred], limits=[
     11           np.percentile(membrane_image, [1,99]),
     12           np.percentile(blurred, [1,99])
     13         ])

File c:\structure\code\microfilm\microfilm\microplot.py:123, in microshow(images, cmaps, flip_map, rescale_type, limits, num_colors, proj_type, alpha, channel_names, channel_label_show, channel_label_type, channel_label_size, scalebar_thickness, scalebar_unit_per_pix, scalebar_size_in_units, unit, scalebar_ypos, scalebar_color, scalebar_font_size, scalebar_text_centered, ax, fig_scaling, dpi, label_text, label_location, label_color, label_font_size, label_kwargs, cmap_objects, show_colorbar, microim)
    110     microim = Microimage(images=images, cmaps=cmaps, flip_map=flip_map, rescale_type=rescale_type,
    111     limits=limits, num_colors=num_colors, proj_type=proj_type, alpha=alpha, channel_names=channel_names,
    112     channel_label_show=channel_label_show, channel_label_type=channel_label_type,
   (...)
    118     label_kwargs=label_kwargs, cmap_objects=cmap_objects, show_colorbar=show_colorbar
    119     )
    121 microim.rescale_type = colorify.check_rescale_type(microim.rescale_type, microim.limits)
--> 123 converted, cmap_objects, image_min_max = colorify.multichannel_to_rgb(microim.images, cmaps=microim.cmaps, flip_map=microim.flip_map,
    124                                 rescale_type=microim.rescale_type, limits=microim.limits,
    125                                 num_colors=microim.num_colors, proj_type=microim.proj_type,
    126                                 alpha=microim.alpha, cmap_objects=microim.cmap_objects)
    127 microim.cmap_objects = cmap_objects
    128 microim.image_min_max = image_min_max

File c:\structure\code\microfilm\microfilm\colorify.py:414, in multichannel_to_rgb(images, cmaps, flip_map, rescale_type, limits, num_colors, proj_type, alpha, cmap_objects)
    412 for ind, im in enumerate(images):
    413     if isinstance(cmaps[ind], str):
--> 414         col_by_name = colorify_by_name(
    415             im, cmap_name=cmaps[ind],
    416             flip_map=flip_map[ind],
    417             rescale_type=rescale_type[ind],
    418             limits=limits[ind],
    419             num_colors=num_colors)
    420         colorified.append(col_by_name[0])
    421         cmap_objects.append(col_by_name[1])

File c:\structure\code\microfilm\microfilm\colorify.py:161, in colorify_by_name(image, cmap_name, flip_map, rescale_type, limits, num_colors)
    128 def colorify_by_name(image, cmap_name, flip_map=False, rescale_type='min_max', limits=None, num_colors=256):
    129     """
    130     Return 2D image as 3D RGB stack colored with a given colormap.
    131     
   (...)
    158 
    159     """
--> 161     image, min_max = rescale_image(image, rescale_type=rescale_type, limits=limits)
    163     cmap = cmaps_def(cmap_name, num_colors=num_colors, flip_map=flip_map)
    165     image_colored = cmap(image)

File c:\structure\code\microfilm\microfilm\colorify.py:253, in rescale_image(image, rescale_type, limits)
    251     if limits is None:
    252         raise Exception(f"You need to provide explicit intensity limits of the form [min, max]")
--> 253     image_rescaled = rescale_intensity(image, in_range=(limits[0], limits[1]), out_range=(0,1))
    254     min_max = (limits[0], limits[1])
    255 return image_rescaled, min_max

File ~\miniconda3\envs\bio_39\lib\site-packages\skimage\exposure\exposure.py:582, in rescale_intensity(image, in_range, out_range)
    579 else:
    580     out_dtype = _output_dtype(out_range, image.dtype)
--> 582 imin, imax = map(float, intensity_range(image, in_range))
    583 omin, omax = map(float, intensity_range(image, out_range,
    584                                         clip_negative=(imin >= 0)))
    586 if np.any(np.isnan([imin, imax, omin, omax])):

File ~\miniconda3\envs\bio_39\lib\site-packages\skimage\exposure\exposure.py:429, in intensity_range(image, range_values, clip_negative)
    427     i_min = np.min(image)
    428     i_max = np.max(image)
--> 429 elif range_values in DTYPE_RANGE:
    430     i_min, i_max = DTYPE_RANGE[range_values]
    431     if clip_negative:

TypeError: unhashable type: 'numpy.ndarray'

Is there maybe another way to specify contrast limits for channels individually?

Handling masks as boolean

Currently microshow returns an error when trying to plot a boolean (e.g. coming out of thresholding). There should be a default setting taking care of this, probably just as a BW image.

Handle float images

Currently, plotting functions raise an error if one tries to plot a non-integer image. It should be possible to plot such images by automatically converting them to the closest integer. A warning should be raised in such a case, and an explicit parameter should be added like convert_to_int to avoid raising the warning.

Mutli-channel single tiff

At the moment, the class MultiPageTiff can only take a folder with multiple single-channel multipage tiffs as input. This should be updated so that CTXY data can also be directly ingested e.g. via an intermediate call the the Numpy format.

Multi-channel

At the moment it's only possible to load a single channel with the load_frame function. It would be nice to be able to say something like load_frame(channel=None, frame=0) or load_frame(channel=['cherry', 'GFP'], frame=0) to load all or several channels at once.

Error when micro-showing images of type float

Hi @guiwitz ,

I'm hitting a little bug when trying to show two images of float type. When executing this code:

from skimage.data import cells3d
from microfilm.microplot import microshow
from skimage.filters import gaussian

data = cells3d()
membrane_image = data[30,1]

blurred = gaussian(image, sigma=5)

microshow([membrane_image, blurred])

I receive this error:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Input In [24], in <module>
      6 membrane_image = data[30,1]
      8 blurred = gaussian(image, sigma=5)
---> 10 microshow([membrane_image, blurred])

File ~\miniconda3\envs\bio_39\lib\site-packages\microfilm\microplot.py:107, in microshow(images, cmaps, flip_map, rescale_type, limits, num_colors, proj_type, channel_names, channel_label_show, channel_label_type, channel_label_size, scalebar_thickness, scalebar_unit_per_pix, scalebar_size_in_units, unit, scalebar_ypos, scalebar_color, scalebar_font_size, scalebar_text_centered, ax, fig_scaling, dpi, label_text, label_location, label_color, label_font_size, microim)
    103 #microim.images = colorify.check_input(microim.images)
    105 microim.rescale_type = colorify.check_rescale_type(microim.rescale_type, microim.limits)
--> 107 converted = colorify.multichannel_to_rgb(microim.images, cmaps=microim.cmaps, flip_map=microim.flip_map,
    108                                 rescale_type=microim.rescale_type, limits=microim.limits,
    109                                 num_colors=microim.num_colors, proj_type=microim.proj_type)
    111 if microim.cmaps is None:
    112         rgb = ['pure_red', 'pure_green', 'pure_blue']

File ~\miniconda3\envs\bio_39\lib\site-packages\microfilm\colorify.py:315, in multichannel_to_rgb(images, cmaps, flip_map, rescale_type, limits, num_colors, proj_type)
    311 if (limits is None) or (not any(isinstance(i, list) for i in limits)):
    312     limits = [limits for i in range(len(images))]
    314 converted = combine_image(
--> 315     [colorify_by_name(
    316         im, cmap_name=cmaps[ind],
    317         flip_map=flip_map[ind],
    318         rescale_type=rescale_type[ind],
    319         limits=limits[ind],
    320         num_colors=num_colors) for ind, im in enumerate(images)
    321     ], proj_type=proj_type)
    323 return converted

File ~\miniconda3\envs\bio_39\lib\site-packages\microfilm\colorify.py:315, in <listcomp>(.0)
    311 if (limits is None) or (not any(isinstance(i, list) for i in limits)):
    312     limits = [limits for i in range(len(images))]
    314 converted = combine_image(
--> 315     [colorify_by_name(
    316         im, cmap_name=cmaps[ind],
    317         flip_map=flip_map[ind],
    318         rescale_type=rescale_type[ind],
    319         limits=limits[ind],
    320         num_colors=num_colors) for ind, im in enumerate(images)
    321     ], proj_type=proj_type)
    323 return converted

File ~\miniconda3\envs\bio_39\lib\site-packages\microfilm\colorify.py:110, in colorify_by_name(image, cmap_name, flip_map, rescale_type, limits, num_colors)
     81 def colorify_by_name(image, cmap_name, flip_map=False, rescale_type='min_max', limits=None, num_colors=256):
     82     """
     83     Return 2D image as 3D RGB stack colored with a given colormap.
     84     
   (...)
    107 
    108     """
--> 110     image = rescale_image(image, rescale_type=rescale_type, limits=limits)
    112     cmap = cmaps_def(cmap_name, num_colors=num_colors, flip_map=flip_map)
    114     image_colored = cmap(image)

File ~\miniconda3\envs\bio_39\lib\site-packages\microfilm\colorify.py:184, in rescale_image(image, rescale_type, limits)
    162 """
    163 Rescale the image between 0-1 according to a rescaling type.
    164 
   (...)
    180     
    181 """
    183 if not np.issubdtype(image.dtype, np.unsignedinteger):
--> 184     raise Exception(f"Image should be unsigned integer but yours is {image.dtype}")   
    186 max_of_dtype = np.iinfo(image.dtype).max
    187 image = image.astype(np.float64)

Exception: Image should be unsigned integer but yours is float64

I'm wondering if it would be possible to also allow images of type float to be shown?

Thanks!
Robert

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.