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 docs for calculating structure tensor #34

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
44 changes: 44 additions & 0 deletions docs/structure-tensor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Calculate Structure Tensors

## Prerequisites

Ensure the [repository](https://github.com/Tinggong/structens) is cloned and its dependencies are installed.
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is a private repository.

Copy link
Member

Choose a reason for hiding this comment

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

Just confirming that this is intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me ask Ting. We can probably make this public.

Copy link

Choose a reason for hiding this comment

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

I think it's better to have a public repository under lincbrain and we still need some work to test and document the code before making it public. So it's okay to remove the link to the repository for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with Ting's suggestion that creates another repo under lincbrain. As this is currently internal, we could probably have the link to the current repo and change it once we move a staged version to lincbrain. How does this sound?

Copy link
Member

Choose a reason for hiding this comment

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

That sounds good, thanks.


## Steps to Calculate Structure Tensor

1. Run Structure Tensor Calculation

Use the process_zarr function to compute the structure tensor from your input Zarr file. Adjust sigma and rho to control the smoothing parameters:
```
input = "/scratch/input.zarr"
output = "/scratch/output.zarr"
process_zarr(input, output, sigma=0, rho=5)
• sigma: Controls the Gaussian smoothing applied before computing derivatives.
• rho: Controls the Gaussian smoothing applied after computing the tensor.
```
2. Generate Pyramid for Multi-Resolution Data

To enable visualization or efficient access, create a resolution pyramid with generate_pyramid:
```
generate_pyramid(Zarr.zopen(output, "w"), levels=6, mode="mean")

• levels: Specifies the number of pyramid levels.
• mode: Determines the aggregation method (e.g., mean).
```
3. Add OME Metadata

To make the output Zarr file compatible with tools like Neuroglancer, write OME-compliant metadata:

```
write_ome_metadata(Zarr.zopen(output, "w"), ["c", "z", "y", "x"])

````
Example Workflow
1. Input: /scratch/input.zarr
2. Output: /scratch/output.zarr
```
process_zarr("/scratch/input.zarr", "/scratch/output.zarr", sigma=0, rho=5)
generate_pyramid(Zarr.zopen("/scratch/output.zarr", "w"), levels=6, mode="mean")
write_ome_metadata(Zarr.zopen("/scratch/output.zarr", "w"), ["c", "z", "y", "x"])
```
This pipeline will produce a multi-resolution Zarr dataset ready for visualization and further analysis.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ nav:
- Welcome: "index.md"
- Upload data: "upload.md"
- Visualize data in Neuroglancer: "neuroglancer.md"
- Calculate Structure Tensor: "structure-tensor.md"
- Webknossos:
- Add Webknossos dataset: "webknossos-add-dataset.md"
- Deployment: https://github.com/lincbrain/webknossos/blob/ak-dev/LINC_DEPLOYMENT.md
Expand Down
Loading