Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add wingdisc functionality #60

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e35e93d
Downsample fly-wing-disc images using tif files as source
Skxsmy Jan 24, 2025
fa40778
update toml file for wingdisc and reorganized the the load_image func…
Skxsmy Jan 30, 2025
254a5dc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 31, 2025
61c4d4b
rearrange files and add a fake test
Skxsmy Feb 3, 2025
87b5ce4
Merge remote-tracking branch 'origin/main'
Skxsmy Feb 3, 2025
215a881
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 3, 2025
d9aabe0
A simple version of mirroring image function added and briefly tested
Skxsmy Feb 12, 2025
09550e6
A improved version of mirroring image function added and briefly tested
Skxsmy Feb 12, 2025
046d2e3
Improved functionality of wing-disc.py
Skxsmy Feb 20, 2025
ca97b1d
Further improved functionality of wing-disc.py
Skxsmy Feb 20, 2025
39f778b
Further further improved functionality of wing-disc.py
Skxsmy Feb 20, 2025
74d2a8a
Use np.flip(axis=2) instead of self-written mirroring function.
Skxsmy Feb 20, 2025
bb4e389
Improved wing-disc functionality
Skxsmy Feb 21, 2025
882de75
Merge remote-tracking branch 'origin/main'
Skxsmy Feb 21, 2025
333cf82
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 21, 2025
641dd49
Merge branch 'brainglobe:main' into main
Skxsmy Feb 21, 2025
c91b4a6
Solve the downsamplping problem
Skxsmy Feb 24, 2025
8535845
Merge remote-tracking branch 'origin/main'
Skxsmy Feb 24, 2025
c8531ce
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 24, 2025
aa523d0
Add lines to record the path in txt files
Skxsmy Feb 25, 2025
7d22bb1
Duplicated/untidy files deleted
Skxsmy Feb 25, 2025
fcc2581
updated pull version
Skxsmy Feb 25, 2025
8f25642
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 25, 2025
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
Next Next commit
Downsample fly-wing-disc images using tif files as source
Skxsmy committed Jan 24, 2025
commit e35e93d954dca8b2d55a9a7359612ed48daff1ba
63 changes: 63 additions & 0 deletions examples/drosophila/wing-disc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import argparse
from pathlib import Path

from loguru import logger

from brainglobe_template_builder.preproc.transform_utils import downsample_anisotropic_image_stack
from brainglobe_utils.IO.image import load_any, save_any
from dask import array as da

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Download source image')
parser.add_argument(
'--source_data_root',
type=str,
help='Path to the source data folder. The source data should contain'
'a subfolder per subject, with picture files within it',
required=True,
)
parser.add_argument(
'--template_building_root',
type=str,
help='Path to the template-building root folder.Results will be '
'written to the rawdata folder.',
required=True
)
parser.add_argument(
'--target_isotropic_resolution',
type=int,
help='Target isotropic resolution',
required=True
)

args = parser.parse_args()

source_data = Path(args.source_data_root)
template_building_root = Path(args.template_building_root)
target_isotropic_resolution = int(args.target_isotropic_resolution)

in_plane_resolution=0.5
out_of_plane_resolution=1

in_plane_factor = int(target_isotropic_resolution/in_plane_resolution)
axial_factor = int(target_isotropic_resolution/in_plane_resolution)

template_raw_data = template_building_root/'rawdata'
template_raw_data.mkdir(exist_ok=True, parents=True)

for sample_folder in source_data.iterdir():
logger.info(f"Downsampling {sample_folder}...")
sample_id = str(sample_folder.name).split("_")[0].lower()
channel = 'membrane'
sample_filename = (
f"sub-{sample_id}_res-{target_isotropic_resolution}"
f"um_channel-{channel}.tif"
)
assert Path(sample_folder).exists(), f"{sample_folder} not found"
original_file_path = Path(sample_folder) / f"{sample_id}_overview-Airyscan-Processing-0{sample_id[-1]}_C1.tif"
assert Path(original_file_path).exists(), f"Filepath {original_file_path} not found"
original_image = load_any(original_file_path)
original_image_dask = da.from_array(original_image,chunks={0: 1, 1: -1, 2: -1})
down_sampled_image = downsample_anisotropic_image_stack(original_image_dask,in_plane_factor,axial_factor)
save_any(down_sampled_image,template_raw_data/sample_filename)
logger.info(f"{sample_filename} downsampled.")