Skip to content

feat(ViSR): Tomography slice viewer - #109

Merged
Abigail-Yates merged 36 commits into
mainfrom
tomo-slice-viewer
Jul 29, 2026
Merged

feat(ViSR): Tomography slice viewer#109
Abigail-Yates merged 36 commits into
mainfrom
tomo-slice-viewer

Conversation

@tomkane-dls

@tomkane-dls tomkane-dls commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

(Abigail: )
this PR

  • adds a slice view to the ViSR Tomography view
  • adds ndarray-ops as a package
  • Makes (most of) the slice and volume view properties persist across tabs (using Local Storage)
  • (& applies prettier to the ViSR Volume View files)

@tomkane-dls

Copy link
Copy Markdown
Contributor Author

I am having some trouble running a local version of visr at the moment, so i will have to see how it actually looks on Monday, but in the meantime i had a look through the code. The main problem with how its implemented is that we are creating so many new objects every time the slider is used, which is something that will be very costly. With our Volume it would likely not seem to make any difference, but it could do with larger arrays, and it will be much tidier to avoid this in general.

This is creating new arrays for every row, every time the slider hits a new value

for (let row = 0; row < volumeShape[1]; row++) {
        const line: number[] = [];

and also the arrays are dynamically sized (they grow every iteration) which is a similar cost

array.push(volumeData[index]);

I think its very helpful to understand the maths underneath so probably better to have done it manually first - but i had a look and actually the problem is solved much more simply than we thought. We don't have to worry about manually striding the data, we can use ndarray to create a volume (i think we should add this to tomography view - I will take another look at the 3D viewer to see if we can simplify that by just passing the volume as well), and then use ndarrays internal logic to do the exact same thing your code is doing but without creating any new objects

const volume = ndarray(volumeData, volumeShape);

and then select a slice with something like

switch(plane)
  case x
    const slice = volume.pick(sliceIndex, null, null);
  case y
  ...

or even:

const slice = volume.pick(
  axis === 0 ? sliceIndex : null,
  ...
);

@tomkane-dls
tomkane-dls requested a review from Abigail-Yates July 3, 2026 15:04
@Abigail-Yates Abigail-Yates linked an issue Jul 17, 2026 that may be closed by this pull request
@Abigail-Yates
Abigail-Yates requested a review from EmsArnold July 27, 2026 08:02
@Abigail-Yates
Abigail-Yates marked this pull request as ready for review July 27, 2026 10:44
@Abigail-Yates
Abigail-Yates marked this pull request as draft July 27, 2026 10:44
@Abigail-Yates
Abigail-Yates marked this pull request as ready for review July 28, 2026 15:44
@Abigail-Yates Abigail-Yates changed the title Tomo slice viewer feat(ViSR): Tomography slice viewer Jul 28, 2026

@EmsArnold EmsArnold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall looks good, just a few comments which make the visualisation a bit smoother and one or two questions about function.

Comment thread apps/visr/src/components/tomography/TomographyView.tsx
Comment thread apps/visr/src/components/tomography/TomographyView.tsx
Comment thread apps/visr/src/components/tomography/TomographyView.tsx
Comment thread apps/visr/src/components/tomography/VolumeViewer.tsx Outdated

@EmsArnold EmsArnold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Coverage currently failing due to a flaky test in RunPlanButton, to be covered by #131

ViSR coverage passes, and changes look good to me

@Abigail-Yates
Abigail-Yates merged commit 4e8368d into main Jul 29, 2026
1 of 4 checks passed
@Abigail-Yates
Abigail-Yates deleted the tomo-slice-viewer branch July 29, 2026 10:34
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.

ViSR: Add a 'Slice view' to the tomography UI

3 participants