Skip to content

Commit

Permalink
Fix a few pep8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaRenauld committed Nov 22, 2023
1 parent 6a4aa6d commit 5af1a73
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 12 deletions.
14 changes: 12 additions & 2 deletions dwi_ml/data/processing/streamlines/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def _get_all_n_previous_dirs(streamlines_dirs: List[torch.Tensor],
for n in range(nb_previous_dirs):
# The n^e previous dir is just the list of dirs, shifted right
if n > 0:
no_n_prev_dirs = torch.cat((unexisting_val, no_n_prev_dirs[:-1,:]))
no_n_prev_dirs = torch.cat((unexisting_val,
no_n_prev_dirs[:-1, :]))
else:
no_n_prev_dirs = torch.cat((unexisting_val, no_n_prev_dirs))

Expand Down Expand Up @@ -309,7 +310,16 @@ def compute_triu_connectivity_from_labels(streamlines, data_labels,
data_labels: np.ndarray
The loaded nifti image.
binary: bool
If true, return a binary matrix.
If True, return a binary matrix.
use_scilpy: bool
If True, uses scilpy's method:
'Strategy is to keep the longest streamline segment
connecting 2 regions. If the streamline crosses other gray
matter regions before reaching its final connected region,
the kept connection is still the longest. This is robust to
compressed streamlines.'
Else, uses simple computation from endpoints. Faster. Also, works with
incomplete parcellation.
"""
real_labels = np.unique(data_labels)[1:]
nb_labels = len(real_labels)
Expand Down
2 changes: 0 additions & 2 deletions dwi_ml/training/utils/batch_samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ def prepare_batch_sampler(dataset, args, sub_loggers_level):
cycles=args.cycles,
rng=args.rng, log_level=sub_loggers_level)



return batch_sampler
2 changes: 1 addition & 1 deletion dwi_ml/unit_tests/test_submethods_connectivity_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def test_connectivity():


if __name__ == '__main__':
test_connectivity()
test_connectivity()
1 change: 0 additions & 1 deletion dwi_ml/unit_tests/test_submethods_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
interpolate_volume_in_neighborhood



nb_points = 2
nb_features = 2
fake_data = torch.zeros(15, 15, 15, nb_features)
Expand Down
1 change: 1 addition & 0 deletions dwi_ml/unit_tests/test_submethods_losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def format_model_outputs(one_fake_model_output):

return fake_model_outputs


def _verify_loss(streamline: Union[torch.Tensor, list],
fake_model_outputs: Union[list, Tuple[list]],
expected_loss: Union[torch.Tensor, np.ndarray, float],
Expand Down
3 changes: 2 additions & 1 deletion dwi_ml/unit_tests/test_train_batch_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from dwi_ml.data.dataset.multi_subject_containers import MultiSubjectDataset
from dwi_ml.unit_tests.utils.expected_values import (
TEST_EXPECTED_SUBJ_NAMES, TEST_EXPECTED_NB_STREAMLINES)
from dwi_ml.unit_tests.utils.data_and_models_for_tests import create_test_batch_sampler, fetch_testing_data
from dwi_ml.unit_tests.utils.data_and_models_for_tests import (
create_test_batch_sampler, fetch_testing_data)


def test_batch_sampler():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ def save_loaded_batch_for_visual_assessment(dataset, ref):
logging.info("*********")
logging.info("Neighborhood:")
# Using ModelForTest with both parents OneInput and Neighborhood.
model = ModelForTest(experiment_name='test',
neighborhood_type='axes',
neighborhood_radius=[1, 2])
model = ModelForTest(experiment_name='test', neighborhood_type='axes',
neighborhood_radius=2)
batch_loader = create_batch_loader(dataset, model)
batch_loader.set_context('training')
_load_directly_and_verify(batch_loader, batch_idx_tuples, ref, 'neighb')
Expand Down
2 changes: 1 addition & 1 deletion dwi_ml/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@
PYTHON_SCRIPTS = glob.glob("scripts_python/*.py")
BASH_SCRIPTS = glob.glob("bash_utilities/*.sh")

PREVIOUS_MAINTAINERS=[]
PREVIOUS_MAINTAINERS = []
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _build_arg_parser():
" connecting 2 regions. If the streamline crosses other gray \n"
" matter regions before reaching its final connected region, \n"
" the kept connection is still the longest. This is robust to \n"
" compressed streamlines.\n"
" compressed streamlines.'\n"
"Else, uses simple computation from endpoints. Faster. Also, "
"works with incomplete parcellation.")

Expand Down

0 comments on commit 5af1a73

Please sign in to comment.