Views with non-fixed steps

Open
#600 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
data

Research direction

Start by reading the ndarray APIs shown in the issue: select, s!, Axis, and Zip, and compare their view and copying behavior. The work is done when the project has a documented way to view arbitrary indices without copying, or clearly establishes that the existing approach is required.

Written by the indexing model from the issue text.

Description

I work with big 4D images, often iterating on Axis(3) to modify it or create a new image. In some cases, I need to iterate only on some indices:

let dwi = Array4::wathever // Loaded from disk
let dwi_indices = vec![2, 3, 10, 13, 17, 21 ...]; // Calculated from dwi
let mut output = Array4::zeros((dwi.dim().0, dwi.dim().1, dwi.dim().2, dwi_indices.len()));
Zip::from(&dwi_indices).and(output.axis_iter_mut(Axis(3))).apply(|&i, volume| {
    let dwi = self.dwi.index_axis(Axis(3), i);
    volume.assign(...);
});

This method works and I can keep it but is there a way to ask for a view with the right indices? select is nice but it makes a copy of the data. s! asks for a step, which I can't give because it's "random". Anything like let dwi = dwi.slice(s![.., .., .., &self.dwi_indices]);?

Dominant language
Rust
Stars
4.3k
Forks
391
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray

All issues in rust-ndarray/ndarray

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.