Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #132 from jhlegarreta/FixPytestFixtureWarning
Browse files Browse the repository at this point in the history
STY: Avoid using `pytest` `tmpdir` fixture as variable name
  • Loading branch information
oesteban authored Mar 22, 2024
2 parents 9331c53 + 764037c commit 3b1e8d0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/eddymotion/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def fit(
)
dwmodel.fit(dwdata.dataobj, n_jobs=n_jobs)

with TemporaryDirectory() as tmpdir:
print(f"Processing in <{tmpdir}>")
with TemporaryDirectory() as tmp_dir:
print(f"Processing in <{tmp_dir}>")
with tqdm(total=len(index_order), unit="dwi") as pbar:
# run a original-to-synthetic affine registration
for i in index_order:
Expand Down Expand Up @@ -174,9 +174,9 @@ def fit(
predicted = dwmodel.predict(data_test[1])

# prepare data for running ANTs
tmpdir = Path(tmpdir)
moving = tmpdir / f"moving{i:05d}.nii.gz"
fixed = tmpdir / f"fixed{i:05d}.nii.gz"
tmp_dir = Path(tmp_dir)
moving = tmp_dir / f"moving{i:05d}.nii.gz"
fixed = tmp_dir / f"fixed{i:05d}.nii.gz"
_to_nifti(data_test[0], dwdata.affine, moving)
_to_nifti(
predicted,
Expand Down Expand Up @@ -214,12 +214,12 @@ def fit(
initial_xform = Affine(
matrix=dwdata.em_affines[i], reference=reference
)
mat_file = tmpdir / f"init_{i_iter}_{i:05d}.mat"
mat_file = tmp_dir / f"init_{i_iter}_{i:05d}.mat"
initial_xform.to_filename(mat_file, fmt="itk")
registration.inputs.initial_moving_transform = str(mat_file)

# execute ants command line
result = registration.run(cwd=str(tmpdir)).outputs
result = registration.run(cwd=str(tmp_dir)).outputs

# read output transform
xform = nt.linear.Affine(
Expand All @@ -229,7 +229,7 @@ def fit(
)
# debugging: generate aligned file for testing
xform.apply(moving, reference=fixed).to_filename(
tmpdir / f"aligned{i:05d}_{int(data_test[1][3]):04d}.nii.gz"
tmp_dir / f"aligned{i:05d}_{int(data_test[1][3]):04d}.nii.gz"
)

# update
Expand Down

0 comments on commit 3b1e8d0

Please sign in to comment.