-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: main
Are you sure you want to change the base?
Conversation
scripts/hipct-distributed.py
Outdated
zarr.save(output_path, processed_data) | ||
print(f"Processed data saved to {output_path}") | ||
|
||
if __name__ == "__main__": |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do - thank you!
scripts/hipct-distributed.py
Outdated
# 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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
scripts/hipct-distributed.py
Outdated
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will use this as a guide: https://github.com/neuroscales/nifti-zarr/tree/impl/0.3/python/python. Thank you!
@balbasty's tool to create the NIfTI-Zarr file.
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.