Skip to content
29 changes: 26 additions & 3 deletions scilpy/tracking/rap.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,33 @@ def rap_multistep_propagate(self, line, prev_direction):


class RAPGraph(RAP):
def __init__(self, mask_rap, propagator, max_nbr_pts, neighboorhood_size):
def __init__(self, mask_rap, propagator, max_nbr_pts, fodf, reps, alpha):
"""
RAPGraph class for the quantum Graph solution for a region.

Parameters
----------
fodf: DataVolume
The FODF volume used to compute the RAP.
reps: int
Number of repetitions used in the quantum circuit.
alpha: float
Initial paramater to search the cost landscape.
"""
super().__init__(mask_rap, propagator, max_nbr_pts)
self.neighboorhood_size = neighboorhood_size
from quactography.scripts.quac_matrix_adj_build import quack_rap

self.fodf = fodf
self.reps = reps
self.alpha = alpha


def rap_multistep_propagate(self, line, prev_direction):
raise NotImplementedError
seg, prev_dir, is_line_valid = (quack_rap(self.mask_rap, self.fodf, line[-1],
reps = self.reps,
alpha = self.alpha,
prev_direction = prev_direction,
theta = self.propagator.theta,
threshold = self.propagator.sf_threshold,))
line.extend(seg)
return line, prev_dir, is_line_valid
19 changes: 16 additions & 3 deletions scripts/scil_tracking_local_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
load_matrix_in_any_format)
from scilpy.image.volume_space_management import DataVolume
from scilpy.tracking.propagator import ODFPropagator
from scilpy.tracking.rap import RAPContinue
from scilpy.tracking.rap import RAPContinue, RAPGraph
from scilpy.tracking.seed import SeedGenerator, CustomSeedsDispenser
from scilpy.tracking.tracker import Tracker
from scilpy.tracking.utils import (add_mandatory_options_tracking,
Expand Down Expand Up @@ -156,9 +156,18 @@ def _build_arg_parser():
'Region-Adaptive Propagation tractography will start within '
'this mask.')
track_g.add_argument('--rap_method', default='None',
choices=['None', 'continue'],
help="Region-Adaptive Propagation tractography method "
choices=['None', 'continue', ['quack']],
help="Region-Adaptive Propagation tractography method." \
"To use option quack, you must install Quacktography "
" [%(default)s]")
track_g.add_argument('--reps', type=int, default=2,
help='Number of repetitions for the RAP method. '
'Default: 2. This is only used for the quack '
'method, not for continue.')
track_g.add_argument('--alpha', type=float, default=1.5,
help='Alpha parameter for the RAP method. '
'Default: 1.5. This is only used for the quack '
'method, not for continue.')

m_g = p.add_argument_group('Memory options')
add_processes_arg(m_g)
Expand Down Expand Up @@ -292,6 +301,10 @@ def main():
if args.rap_method == "continue":
rap = RAPContinue(rap_mask, propagator, max_nbr_pts,
step_size=vox_step_size)
elif args.rap_method == "quack":
rap = RAPGraph(rap_mask, propagator, max_nbr_pts, fodf=dataset, reps=args.reps,
alpha=args.alpha)

else:
rap = None

Expand Down
Loading