Skip to content

Commit

Permalink
Make changes to follow latest scilpy architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaRenauld committed Jan 17, 2024
1 parent c9d2185 commit 99d3139
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion dwi_ml/data/processing/dwi/dwi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from dipy.reconst.shm import sph_harm_lookup
import nibabel as nib
import numpy as np

from scilpy.io.utils import validate_sh_basis_choice
from scilpy.reconst.raw_signal import compute_sh_coefficients
from scilpy.reconst.sh import compute_sh_coefficients

eps = 1e-6

Expand Down
3 changes: 2 additions & 1 deletion dwi_ml/data/processing/streamlines/data_augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from nibabel.streamlines.tractogram import (PerArrayDict, PerArraySequenceDict)
import numpy as np

from scilpy.tracking.tools import resample_streamlines_step_size
from scilpy.tractograms.streamline_operations import \
resample_streamlines_step_size
from scilpy.utils.streamlines import compress_sft


Expand Down
2 changes: 1 addition & 1 deletion dwi_ml/data/processing/streamlines/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from scilpy.tractanalysis.tools import \
extract_longest_segments_from_profile as segmenting_func
from scilpy.tractanalysis.uncompress import uncompress
from scilpy.tractograms.uncompress import uncompress

# We could try using nan instead of zeros for non-existing previous dirs...
DEFAULT_UNEXISTING_VAL = torch.zeros((1, 3), dtype=torch.float32)
Expand Down
3 changes: 2 additions & 1 deletion dwi_ml/testing/projects/transformer_visualisation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

from scilpy.io.streamlines import load_tractogram_with_reference
from scilpy.io.utils import add_reference_arg, add_overwrite_arg, add_bbox_arg
from scilpy.tracking.tools import resample_streamlines_step_size
from scilpy.tractograms.streamline_operations import \
resample_streamlines_step_size
from scilpy.utils.streamlines import compress_sft

from dwi_ml.io_utils import add_logging_arg
Expand Down
6 changes: 3 additions & 3 deletions dwi_ml/tracking/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,18 @@ def prepare_seed_generator(parser, args, hdf_handle):
seed_generator = SeedGenerator(seed_data, seed_res, space=ALWAYS_VOX_SPACE,
origin=ALWAYS_CORNER)

if len(seed_generator.seeds_vox) == 0:
if len(seed_generator.seeds_vox_corner) == 0:
parser.error('Seed mask "{}" does not have any voxel with value > 0.'
.format(args.in_seed))

if args.npv:
# Note. Not really nb seed per voxel, just in average.
nbr_seeds = len(seed_generator.seeds_vox) * args.npv
nbr_seeds = len(seed_generator.seeds_vox_corner) * args.npv
elif args.nt:
nbr_seeds = args.nt
else:
# Setting npv = 1.
nbr_seeds = len(seed_generator.seeds_vox)
nbr_seeds = len(seed_generator.seeds_vox_corner)

seed_header = nib.Nifti1Image(seed_data, affine).header

Expand Down
5 changes: 2 additions & 3 deletions dwi_ml/tracking/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,9 @@ def _gpu_simultaneous_tracking(self):
if seed_count + nb_next_seeds > self.nbr_seeds:
nb_next_seeds = self.nbr_seeds - seed_count

next_seeds = np.arange(seed_count, seed_count + nb_next_seeds)

n_seeds = self.seed_generator.get_next_n_pos(
random_generator, indices, next_seeds)
random_generator, indices, which_seed_start=seed_count,
n=nb_next_seeds)

tmp_lines, tmp_seeds = \
self._get_multiple_lines_both_directions(n_seeds)
Expand Down

0 comments on commit 99d3139

Please sign in to comment.