question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a convenient way to plot a slice from a patient volume?

See original GitHub issue

Is there any convenient way to display for example nth-slice of subject image of subjects_dataset[0] ?

I want to visualize slices as I apply tranforms to them, the only thing I came up with is converting the the 3D Tensor back to .nii image and from that plotting the slice.

Can you suggest any convenient method ?

Thankyou and much appreciated.

Faraz

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (20 by maintainers)

github_iconTop GitHub Comments

2reactions
fepegarcommented, Jun 4, 2020

It depends on what plane you want to visualize. You can just plot data[..., n_slice]. Here’s some code that might be helpful:

https://github.com/fepegar/miccai-educational-challenge-2019/blob/94067cdb99830ea21e51964ac9c20a34c28aaea4/visualization.py#L113-L173

It will look like this: Screen Shot 2020-06-04 at 15 13 59

1reaction
fepegarcommented, Jun 5, 2020

You just need to slice your 3D volume along the third axis, which is the one that goes from inferior (slice 0) to superior (slice 55), if your image is RAS.

size_r, size_a, size_s = data.shape
for k in range(size_s):
    slice = data[:, :, k]. # or just data[..., k]
    plt.imshow(slice)
    plt.show()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Robust Super-resolution Volume Reconstruction from Slice ...
Slice sequential acquisitions do not enable 3D volume representation. In this study, we have developed a novel technique based on a slice acquisition...
Read more >
Plotting an axial slice from a Nifti image? - Community Chat
I'd like to understand how to plot a slice of the Nifti array in a certain orientation, specifically axial. I thought that the...
Read more >
User Interface - 3D Slicer documentation - Read the Docs
Slicer stores all loaded data in a data repository, called the “scene” (or Slicer scene or MRML scene). Each data set, such as...
Read more >
Essential Chart Types for Data Visualization | Tutorial by Chartio
Charts are an essential part of working with data, as they are a way to condense large amounts of data into an easy...
Read more >
Slice timing correction - Matthew Brett on github
But — it would be convenient if all the voxels in one volume correspond to the same time. Otherwise we would need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found