Skip to content

Commit

Permalink
Merge pull request #44 from oanegros/mask-loading
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
oanegros committed Jun 11, 2024
2 parents 63295aa + 3961aea commit 652c436
Show file tree
Hide file tree
Showing 240 changed files with 9,491 additions and 909 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
max-parallel: 4
fail-fast: false
matrix:
blender-version: ["4.0.0"]
blender-version: ["4.1.1"]
os: [ubuntu-latest, windows-latest, macos-13]
# os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.10'
python-version: '3.11.6'
cache: 'pip'
- run: pip install bpy==${{ matrix.blender-version }}
# - run: pip install bpy==${{ matrix.blender-version }}

- name: Install poetry
run: pip install poetry
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
test:
poetry install --with test
poetry pytest -v
python -m pip install .
pytest -v


version := $(shell grep version pyproject.toml | grep -o -E "\b[0-9]+\.[0-9]+\.[0-9]+\b")

template:
cd tif2blender/assets/template && zip -r tif2blender.zip ../../../tif2blender

# git clean -dfX
release:
git clean -dfX
make template
Expand Down
49 changes: 20 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
# tif to blender
This is a project building bioimage support for the open source software blender. This currently exists as the Blender add-on `tif loader` which is able to easily load tif files as volumetric objects in Blender.

This originally started as a script for the [Blender for Biologists workshop](https://github.com/oanegros/Blender_for_Biologists_2023) Because the scope seems to have outgrown this workshop, the development has split off.
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 introduction](https://youtu.be/TCQojYEYxVo) to the tif2blender add-on on youtube.

<img src="./figures/newprettyside.png" width="600"/>

## Current Features
The `tif loader` Blender addon is still under active development, but some notable features are already supported:
The `tif2blender` Blender addon is still under active development, but some notable features are already supported:

- 3D to 5D (zyx to tzcyx in any axis order) tifs are 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

## Video introduction

See the [video introduction](https://youtu.be/TCQojYEYxVo) to the tif2blender add-on on youtube.


## Installing `tif loader`
## Installing `tif2blender`

Download:

- Download blender from https://www.blender.org/download/. Download Blender 4.0.x for the newest version of tif2blender. Blender 3.5 and 3.6 are also supported in different releases, so please check on the releases page!
- Download blender from https://www.blender.org/download/. Check the supported blender version next to the release!

- Download the tif loader zip file from the [releases page](https://github.com/oanegros/tif2blender/releases).
- Download the tif2blender zip file from the [releases page](https://github.com/oanegros/tif2blender/releases).

Start blender.

Install the `tif loader` Add-On:
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 `tif loader` add-on window in `Preferences`: press the tick box to enable, and the arrow to unfold the details
- 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 `tif loader` panel in `Scene Properties`.
This should create the `tif2blender` panel in `Scene Properties`.

## Using `tif loader`
## 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](https://github.com/oanegros/tif2blender/issues).

- The `tif loader` panel should be able to automatically read out your axis order and pixel size, but these can otherwise also manually be entered
- 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 `tif loader` 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.
- 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:
Expand All @@ -57,22 +57,13 @@ Loading with preset environment recently had a small bug, fixed on 7th nov 18:45
- 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:
- A default `Emission Material` is applied. You can find and edit this in the `Shading` tab when selecting a volume (not the container of the volume):
- This takes each channel from an Otsu threshold up. This threshold is set and can be changed in the `Map Range`
- This is piped to the `Emission Strength` of the `Volume shader`.
- A default `Scale bar` is applied. This is implemented as a `Geometry Nodes Modifier` of the `Container` of the volumes. You can find and edit this in the `Geometry Nodes` tab if you have the `Container` selected:
- By default this starts at 10 `µm per tick` but this can be changed.
- This has many visualization options, default is a thin `grid` with `crosshatch ticks` on the major axes
- By default this has `Frontface culling` on, so that this only renders the back axes from the view angle, however, you can also specifically select which axes to draw.
- The `crosshatch` ticks can be replaced with any geometry.
Upon load, multiple defaults are applied, but all of these can be changed as granularly as you want.

More tutorial-like description can be found at [Blender for Biologists](https://github.com/oanegros/Blender_for_Biologists_2023). However, this asssumes a less capable version of `tif loader` that does not apply an initial material, for didactic purposes.

## Updating `tif loader`
To update the `tif loader` add-on (future versions may have bugfixes, new features) a few steps need to be taken:
## 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 `tif loader` add-on
- Go to `Add-Ons` tab in `Preferences` and find the `tif2blender` add-on
- Press `Remove`
- Restart Blender
- Install the new version.
Loading

0 comments on commit 652c436

Please sign in to comment.