Giter Club home page Giter Club logo

tif2blender's Introduction

tif to blender

This is a project building bioimage support for the open source software blender. This currently exists as the Blender add-on tif2blender which is able to easily load tif files as volumetric objects in Blender.

Please make some pretty figures with this add-on! If you post using this addon on social media please either tag me (@GrosOane on twitter) or use hashtag #tif2blender.

Video introduction

See the video introductions to the tif2blender add-on on youtube. There's multiple playlists on the account, and they'll show you how to go from installing to rendering a presentation-ready video for fluorescence and electron microscopy.

Current Features

The tif2blender Blender addon is still under active development, but some notable features are already supported:

  • up to 5D (up to tzcyx in any axis order) tifs are supported.
  • Axes order and pixel size will be attempted to be read out automatically
  • Otsu initial volumetric emission material is applied
  • Scale bars are added to the Geometry Nodes container of your volumetric data

Installing tif2blender

Download:

Start blender.

Install the tif2blender Add-On:

  • In Blender go to Edit > Preferences
  • Go to Add-Ons tab in Preferences
  • Press Install and give the tif_loader.zip file (as .zip)
  • In the added tif2blender add-on window in Preferences: press the tick box to enable, and the arrow to unfold the details
  • in the details press install tifffile
  • (if this fails please try restarting blender and seeing if it can then find tifffile)

This should create the tif2blender panel in Scene Properties.

Using tif2blender

Load in tif-files in the file explorer from the panel in Scene Properties.

Loading with preset environment recently had a small bug, fixed on 7th nov 18:45. So either uncheck this or update your tif_loader(see below), if you have this issue. For any other problems, please open an issue.

  • The tif2blender panel should be able to automatically read out your axis order and pixel size, but these can otherwise also manually be entered
  • Any tif stack from zyx to tzcyx (in any axis order) is supported
  • The tif2blender resaves your tif as a .vdb file (in a blender_volumes subfolder) and loads this as a volume object in your blender scene, connected to a Container object.
  • With large files (over 2048 px in an axis), the volumes will be split to avoid blender crashes.
  • With the Import option: Force Remake you will force remaking the vdb files, if this is unchecked and the vdb files exist, these will be loaded.
  • With the Import option: Preset Environment some default environment variables will be set. These overwrite current other environment settings, but are useful for quickly looking at data:
    • Sets background to black (as emission material is default)
    • Sets Eevee volumetric tile_size to 2 px (might be heavy for enormous data)
    • Sets Cycles Samples to manageable numbers for volumetric data
    • Sets View Transform to Standard (the default Filmic crunches dynamic range post-render)

Upon load, multiple defaults are applied, but all of these can be changed as granularly as you want.

Updating tif2blender

To update the tif2blender add-on (future versions may have bugfixes, new features) a few steps need to be taken:

  • In Blender go to Edit > Preferences
  • Go to Add-Ons tab in Preferences and find the tif2blender add-on
  • Press Remove
  • Restart Blender
  • Install the new version.

tif2blender's People

Contributors

oanegros 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tif2blender's Issues

set cache directory

right now it is always next to the images, which is not very easy to clean up

Scale bars

There is an inherent issue with scale bars for data visualization with perspective cameras, where a scale bar only works as long as the perspective can be accurately assessed by the human viewer, which can be hard with microscopy as normal landmarks do not exist.
options:

  • simple axes of cylinders at 1 µm (simplest, minimal solution, asks the user to take care themselves)
  • box enclosing the entire volume with ticks (gives perspective inference, the solution that fiji BVV does, however, this doesnt work with all camera placements)
  • conversion factor of 1 blender meter to µm (or even setting the blender unit to physical µm, although this may be unfeasible). Communicating this may be hard, but an option could be adding a geometry nodes string-to-mesh of the conversion factor.

This could also all be optional inside a single GN node. I'm very open to other suggestions for this.

Bump to blender 4

a lot more is possible there but some of the syntax (around group input/output for example) has changed.

Some errors were reported during loading

The node named "Material Output" is not created before it is used.
Thanks!

Python: Traceback (most recent call last):
File "C:\Users\Youming Xiao\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\tif2blender\ui\ui.py", line 75, in execute
load.load()
File "C:\Users\Youming Xiao\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\tif2blender\load.py", line 117, in load
vol_obj, volume_inputs = load_volume(volume_inputs, bbox_px, scale, cache_coll, base_coll, emission)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Youming Xiao\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\tif2blender\load_components\load_volume.py", line 142, in load_volume
materials = volume_materials(volume_inputs, emission_setting)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Youming Xiao\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\tif2blender\load_components\load_volume.py", line 106, in volume_materials
nodes.get("Material Output").location = (700,00)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'location'
c22dc398776f35af4c2ba55aa85c1f3

update documentation!

time support is now done, guide people to how to change scale bars and what new import options do

Infer pixel size and axes from FIJI metadata

As this is built on tifs, and fiji/imagej has such dominance, i think trying to read imagej_metadata for pixel size and axes order would be a nice QoL improvement.
This could be under a separate infer operator in the tif loader window

add otsu as checkmark

otsu is slow, is nice to be able to turn off for large volumes

will be for a version 0.0.2 before moving to blender 4, together with tests created in #29, to have a 3.5/3.6 version of tif loader that is functional

Missing µm per tick text indication in the scene

In the scale bounding box geometry node I would add a node from "um per tick" to a "value to string" and then "string to curve" and "curve to mesh" so that the length corresponding to a single tick is displayed at 0,0,0

vdb files in subfolder

In the current folders the vdb files are next to the tif, which is annoying for large volumes with chunked vdbs, might be nice to reintroduce a tmp folder for vdbs

Support video data

vdb loading by frame is supported in blender, currently the addon only handles single frames. Might be good to move to a frame-by-frame folder with all chunks per frame.

Note: this may also change orders of chunk loading.

chunked volume to mesh

Currently, we need to load in separate volumes for large microscopy datasets, where the volume to mesh operators only work on a single mesh. So a requirement is some form of operator for making multiple, linked meshes with volume to mesh operators.

This might be easiest by adding the same GN modifier to all linked meshes, and then doing some magic with volume to mesh nodes in there. this would need to be tested, though.

segmentation mask load as mesh

have in import options a checkmark for 'mask':
this gives a channel selector which channel the mask is in
The mask can then be loaded as mesh (marching cubes per unique integer value)

load with basic material applied

currently the first actions we do upon load are the same, adding Attribute > Map Range > Principled Volume with maybe Mix Shader of multiple for multiple channels, to make a first visualization of the data.

It would be nice to have this automatically upon load of a new tif, to also handle automatic linking of chunked volumes.

Should this automatically threshold? Maybe Otsu thresholding upon load would be good, and make you immediately capable of looking at your data.

LUTs in tif2blender + Apply LUT... in node tools

Try to create a LUT-like interface for shaders by piping from white shader -> shader to RGB -> LUT and use Node tools in Blender 4 to create an Apply LUT.. interface.
How will this work for selecting channels?

Volume loads but no nodes in shading or geometry

Hi.
Just trying out to load some in vivo data from two photon microscopy (lower SNR than exM etc).
The volume loads (zxy) but no nodes are visible in the shading or geometry editors (screenshot attached).
Any clues?
Thanks!
P.
Uploading tiff2blender_issue.png…

Supporting extra image formats

Supporting extra image formats should be very doable, as the only thing this needs is a python library to import file to numpy array and reading metadata, the only issue in this is making Blender have optional dependencies for each of these files. And that then load and metadata functions need to be dynamically assigned based on file type.

To be clear, tif2blender would then still rewrite to (uncompressed) .vdb files, this is only about the input format into tif2blender.

Data types to support:

  • OME-ZARR (ome-zarr-py)
  • HDF5 (h5py), although this may have require some UI tuning because metadata names (even of the data) are not standardized
  • LZW compressed .tif (imagecodecs with currently required tifffile) as noted in #35 by @hvdrosa
  • .tif sequence (not the easiest to support, as this requires a file list)

Please comment with formats you'd want, or if you think you can help write a load script!

Only a selected slice in Render mode

Hi Oane!

Amazing package! It also works with our cryoET data despite it being intrinsically noisy! (I had some minor issues with LZW compressed TIFs, but it worked nicely for non-compressed ones. I guess it's only a matter of some additional libraries I was missing to be able to read it).

I wanted to ask if you have implemented (or know) an easy solution to display and render only one selected slice (as one would do in the Data> Viewport display > Slice)
image

The issue is that whenever I go to render/shading mode, it displays the full volume and not only the selected slice (as in viewport)
image.

Best,
Higor

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.