diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml index 7ecf15c..9ed0f11 100644 --- a/.github/workflows/pr-coverage.yml +++ b/.github/workflows/pr-coverage.yml @@ -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 diff --git a/python/ouroboros/helpers/files.py b/python/ouroboros/helpers/files.py index a72d437..80e4b09 100644 --- a/python/ouroboros/helpers/files.py +++ b/python/ouroboros/helpers/files.py @@ -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 diff --git a/python/ouroboros/pipeline/backproject_pipeline.py b/python/ouroboros/pipeline/backproject_pipeline.py index 76ec7b0..e5955fc 100644 --- a/python/ouroboros/pipeline/backproject_pipeline.py +++ b/python/ouroboros/pipeline/backproject_pipeline.py @@ -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)): diff --git a/python/test/helpers/test_files.py b/python/test/helpers/test_files.py index e32fe74..0cd18b8 100644 --- a/python/test/helpers/test_files.py +++ b/python/test/helpers/test_files.py @@ -1,4 +1,5 @@ import os +from pathlib import Path from tifffile import imwrite from ouroboros.helpers.files import ( format_backproject_output_file, @@ -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( @@ -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 diff --git a/src/renderer/src/components/MenuPanel/components/FileExplorer/components/DraggableEntry/DraggableEntry.tsx b/src/renderer/src/components/MenuPanel/components/FileExplorer/components/DraggableEntry/DraggableEntry.tsx index f417c35..233228d 100644 --- a/src/renderer/src/components/MenuPanel/components/FileExplorer/components/DraggableEntry/DraggableEntry.tsx +++ b/src/renderer/src/components/MenuPanel/components/FileExplorer/components/DraggableEntry/DraggableEntry.tsx @@ -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