Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/pr-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ on:
pull_request:
branches:
- main

env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

jobs:
coverage:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion python/ouroboros/helpers/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_sorted_tif_files(directory):
files = os.listdir(directory)

# Filter to include only .tif files and sort them numerically
tif_files = sorted((file for file in files if file.endswith(".tif")))
tif_files = sorted((file for file in files if file.endswith((".tif", ".tiff"))))

return tif_files

Expand Down
2 changes: 1 addition & 1 deletion python/ouroboros/pipeline/backproject_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _process(self, input_data: any) -> tuple[any, None] | tuple[None, any]:

# Save the straightened volume to a new tif file
with tifffile.TiffWriter(new_straightened_volume_path) as tif:
if straightened_volume_path.endswith(".tif"):
if straightened_volume_path.endswith((".tif", ".tiff")):
# Read the single tif file
with tifffile.TiffFile(straightened_volume_path) as tif_in:
for i in range(len(tif_in.pages)):
Expand Down
46 changes: 32 additions & 14 deletions python/test/helpers/test_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path
from tifffile import imwrite
from ouroboros.helpers.files import (
format_backproject_output_file,
Expand All @@ -22,9 +23,16 @@ def test_load_and_save_tiff_from_slices(tmp_path):
slices_folder = tmp_path / "slices"
slices_folder.mkdir()

input_names = [slices_folder / f"slice_{i:03d}.tif" for i in range(5)]

# Change some names to .tiff to ensure both .tif and .tiff are read.
from random import randrange
for i in [randrange(5) for j in range(2)]:
input_names[i] = input_names[i].with_suffix('.tiff')

# Create some sample tiff files
for i in range(5):
imwrite(slices_folder / f"slice_{i:03d}.tif", data=[[i]])
for name in input_names:
imwrite(name, data=[[i]])

output_file_path = tmp_path / "output.tif"
load_and_save_tiff_from_slices(
Expand All @@ -44,36 +52,46 @@ def test_load_and_save_tiff_from_slices(tmp_path):


def test_get_sorted_tif_files(tmp_path):
import random

# Generate some sample tiff files
filenames = [f"{i:03d}.tif" for i in range(101)]
original_filenames = filenames.copy()
filenames = [Path(tmp_path, f"{i:03d}.tif") for i in range(101)]

# Randomize the order
import random
# Ensure both .tif and .tiff files are handled.
for i in [random.randrange(101) for j in range(35)]:
filenames[i] = filenames[i].with_suffix('.tiff')

original_filenames = [path.name for path in filenames]

# Randomize the order
random.shuffle(filenames)

# Create the files
for filename in filenames:
(tmp_path / filename).touch()
for path in filenames:
path.touch()

sorted_files = get_sorted_tif_files(str(tmp_path))
assert sorted_files == original_filenames


def test_get_sorted_tif_files_prefix(tmp_path):
import random

# Generate some sample tiff files
filenames = [f"slice_{i:03d}.tif" for i in range(101)]
original_filenames = filenames.copy()
filenames = [Path(tmp_path, f"slice_{i:03d}.tif") for i in range(101)]

# Randomize the order
import random
# Ensure both .tif and .tiff files are handled.
for i in [random.randrange(101) for j in range(35)]:
filenames[i] = filenames[i].with_suffix('.tiff')

original_filenames = [path.name for path in filenames]

# Randomize the order
random.shuffle(filenames)

# Create the files
for filename in filenames:
(tmp_path / filename).touch()
for path in filenames:
path.touch()

sorted_files = get_sorted_tif_files(str(tmp_path))
assert sorted_files == original_filenames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function DraggableEntry({
handleChange: (event: InputEvent) => void
}): JSX.Element {
// Determine the type of the entry
const type = node.children ? 'folder' : node.name.endsWith('.tif') ? 'image' : 'file'
const type = node.children ? 'folder' : (node.name.endsWith('.tif') || node.name.endsWith('.tiff')) ? 'image' : 'file'
const isFolder = type === 'folder'
const isEmpty = !node.children || Object.keys(node.children).length === 0

Expand Down