Skip to content

Commit

Permalink
fix pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbore committed Jan 27, 2025
1 parent 251e9b6 commit 3ee923d
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion scilpy/denoise/asym_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ def cosine_filtering(in_sh, sh_order=8, sh_basis='descoteaux07',

# We want a B matrix to project on an inverse sphere to have the sf on
# the opposite hemisphere for a given vertice
neg_B = sh_to_sf_matrix(Sphere(xyz=-sphere.vertices), sh_order_max=sh_order,
neg_B = sh_to_sf_matrix(Sphere(xyz=-sphere.vertices),
sh_order_max=sh_order,
basis_type=sh_basis, return_inv=False,
full_basis=in_full_basis, legacy=is_legacy)

Expand Down
3 changes: 2 additions & 1 deletion scilpy/image/volume_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ def register_image(static, static_grid2world, moving, moving_grid2world,

sigmas = [8.0, 4.0, 2.0, 1.0] if fine else [8.0, 4.0, 2.0]
factors = [8, 4, 2, 1.0] if fine else [8, 4, 2]
metric = MutualInformationMetric(nbins=nbins, sampling_proportion=sampling_prop)
metric = MutualInformationMetric(nbins=nbins,
sampling_proportion=sampling_prop)
reg_obj = AffineRegistration(metric=metric, level_iters=level_iters,
sigmas=sigmas, factors=factors, verbosity=0)

Expand Down
3 changes: 1 addition & 2 deletions scilpy/reconst/frf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
from dipy.segment.mask import applymask
import numpy as np

from scilpy.gradients.bvec_bval_tools import (check_b0_threshold,
is_normalized_bvecs,
from scilpy.gradients.bvec_bval_tools import (is_normalized_bvecs,
normalize_bvecs,
DEFAULT_B0_THRESHOLD)

Expand Down
3 changes: 2 additions & 1 deletion scilpy/reconst/sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ def compute_rish(sh, mask=None, full_basis=False):
n_indices_per_order = np.bincount(order_ids)[::step]

# Get start index of each order (e.g. for order 6 : [0,1,6,15])
order_positions = np.concatenate([[0], np.cumsum(n_indices_per_order)])[:-1]
order_positions = np.concatenate([[0],
np.cumsum(n_indices_per_order)])[:-1]

# Get paired indices for np.add.reduceat, specifying where to reduce.
# The last index is omitted, it is automatically replaced by len(array)-1
Expand Down
10 changes: 6 additions & 4 deletions scilpy/segment/recobundlesx.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ def _cluster_model_bundle(self, model_clust_thr, identifier):
len_centroids = len(self.model_centroids)
if len_centroids > 1000:
logging.warning('Model {0} simplified at threshold '
'{1}mm with {2} centroids'.format(identifier,
str(model_clust_thr),
str(len_centroids)))
'{1}mm with '
'{2} centroids'.format(identifier,
str(model_clust_thr),
str(len_centroids)))

def _reduce_search_space(self, neighbors_reduction_thr=18):
"""
Expand Down Expand Up @@ -195,7 +196,8 @@ def _register_model_to_neighb(self, select_model=1000, select_target=1000,
slr_transform_type_id = possible_slr_transform_type[slr_transform_type]
if slr_transform_type_id >= 0:
init_transfo_dof = np.zeros(3)
slr = StreamlineLinearRegistration(metric=metric, method="L-BFGS-B",
slr = StreamlineLinearRegistration(metric=metric,
method="L-BFGS-B",
x0=init_transfo_dof,
bounds=bounds_dof[:3],
num_threads=1)
Expand Down
4 changes: 2 additions & 2 deletions scilpy/tractanalysis/afd_along_streamlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def afd_map_along_streamlines(sft, fodf, fodf_basis, length_weighting,
def afd_and_rd_sums_along_streamlines(sft, fodf, fodf_basis,
length_weighting, is_legacy=True):
"""
Compute the mean Apparent Fiber Density (AFD) and mean Radial fODF (radfODF)
maps along a bundle.
Compute the mean Apparent Fiber Density (AFD) and
mean Radial fODF (radfODF) maps along a bundle.
Parameters
----------
Expand Down
11 changes: 6 additions & 5 deletions scilpy/tractograms/tractogram_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,8 @@ def cut_streamlines_alter(sft, min_dice=0.90, epsilon=0.01, from_end=False):
"""
Cut streamlines based on a dice similarity metric.
The function will keep removing points from the streamlines until the dice
similarity between the original and the cut tractogram is close to min_dice.
similarity between the original and the cut tractogram is close
to min_dice.
Parameters
----------
Expand All @@ -1059,8 +1060,8 @@ def cut_streamlines_alter(sft, min_dice=0.90, epsilon=0.01, from_end=False):
Stopping criteria for convergence. The maximum difference between the
dice similarity and min_dice.
from_end: bool
If True, the streamlines will be cut from the end. Else, the streamlines
will be cut from the start.
If True, the streamlines will be cut from the end. Else,
the streamlines will be cut from the start.
Returns
-------
Expand Down Expand Up @@ -1321,8 +1322,8 @@ def transform_streamlines_alter(sft, min_dice=0.90, epsilon=0.01):
curr_density_map = compute_tract_counts_map(curr_sft.streamlines,
sft.dimensions)
dice, _ = compute_dice_voxel(original_density_map, curr_density_map)
logging.debug(f'Transformed {np.round(to_pick * 360, 6)} degree on axis '
f'{axis}, dice: {dice}')
logging.debug(f'Transformed {np.round(to_pick * 360, 6)} degree '
f'on axis {axis}, dice: {dice}')
last_pick[axis] = to_pick

if dice < min_dice:
Expand Down
3 changes: 0 additions & 3 deletions scripts/scil_bundle_clean_qbx_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ def keypress_callback(obj, _):
sft_rejected_on_size, filename_rejected_on_size = [], []
concat_streamlines = []

ref_bundle = load_tractogram_with_reference(
parser, args, args.in_bundles[0])

for filename in args.in_bundles:
basename = os.path.basename(filename)
sft = load_tractogram_with_reference(parser, args, filename)
Expand Down
1 change: 0 additions & 1 deletion scripts/scil_fibertube_score_tractogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@

import os
import json
import numba
import argparse
import logging
import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/test_tracking_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_execution_tracking_ptt(script_runner, monkeypatch):
assert ret.success


def test_execution_sphere_subdivide(n=script_runner, monkeypatch):
def test_execution_sphere_subdivide(script_runner, monkeypatch):
monkeypatch.chdir(os.path.expanduser(tmp_dir.name))
in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz')
in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz')
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_execution_tracking_fodf_prob_pmf_mapping(script_runner, monkeypatch):
assert ret.success


def test_execution_tracking_ptt(script_runner, monkeypatch):
def test_execution_tracking_ptt_with_probe(script_runner, monkeypatch):
monkeypatch.chdir(os.path.expanduser(tmp_dir.name))
in_fodf = os.path.join(SCILPY_HOME, 'tracking', 'fodf.nii.gz')
in_mask = os.path.join(SCILPY_HOME, 'tracking', 'seeding_mask.nii.gz')
Expand Down

0 comments on commit 3ee923d

Please sign in to comment.