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

[WIP] Create script for distributed processing of HIP-CT datasets. #5

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Laurabtt152
Copy link

@Laurabtt152 Laurabtt152 commented Dec 24, 2024

This code is a work in process to facilitate the preprocessing and analysis of large 3D imaging datasets, such as those in NIfTI format, by converting them into Zarr format for efficient processing. Leveraging Dask for distributed computation, the pipeline applies techniques like proportional thresholding, CLAHE (contrast enhancement), and 8-bit quantization, with optional masking to isolate regions of interest. The initial focus is to develop a scalable, cluster-enabled computational framework for pre- and post-processing of whole-brain imaging datasets, with initial applications to HiP-CT data and the flexibility to extend to other modalities.

zarr.save(output_path, processed_data)
print(f"Processed data saved to {output_path}")

if __name__ == "__main__":
Copy link
Member

@kabilar kabilar Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Laurabtt152. Let's create a high-level/wrapper function. For an example, please see convert.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do - thank you!

Comment on lines 80 to 83
# Paths
nifti_path = "path/to/input.nii.gz" # Path to the NIfTI file (if applicable)
zarr_path = "path/to/data.zarr" # Path to the Zarr file (output or input)
processed_output_path = "path/to/processed_output.zarr"
Copy link
Member

@kabilar kabilar Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pass these variables in as arguments to the wrapper function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

Comment on lines 18 to 25
def nifti_to_zarr(nifti_path, zarr_path):
"""Convert a NIfTI file to Zarr format."""
img = nib.load(nifti_path)
data = img.get_fdata()
z = zarr.open(zarr_path, mode='w', shape=data.shape, dtype=data.dtype)
z[:] = data
print(f"Converted {nifti_path} to {zarr_path}")
return z
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use @balbasty's tool to create the NIfTI-Zarr file - https://github.com/neuroscales/nifti-zarr/tree/impl/0.3/python

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants