Skip to content

Commit c7afb8f

Browse files
authored
Merge pull request #196 from jhlegarreta/ref/import-close-to-calls-nb-new
REF: Reorder import statements in PET notebook
2 parents cb90840 + c2b7930 commit c7afb8f

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

docs/notebooks/pet_motion_estimation.ipynb

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,8 @@
1010
"from os import getenv\n",
1111
"from pathlib import Path\n",
1212
"\n",
13-
"import nibabel as nib\n",
13+
"from nifreeze.data.pet import PET\n",
1414
"\n",
15-
"from nifreeze.data import pet\n",
16-
"from nifreeze.model import PETModel"
17-
]
18-
},
19-
{
20-
"cell_type": "code",
21-
"execution_count": 2,
22-
"id": "68dc04bd-04d8-49fa-bb21-d5de76afbc63",
23-
"metadata": {},
24-
"outputs": [],
25-
"source": [
2615
"# Install test data from gin.g-node.org:\n",
2716
"# $ datalad install -g https://gin.g-node.org/nipreps-data/tests-nifreeze.git\n",
2817
"# and point the environment variable TEST_DATA_HOME to the corresponding folder\n",
@@ -40,7 +29,7 @@
4029
" DATA_PATH / \"pet_data\" / \"sub-02\" / \"ses-baseline\" / \"pet\" / \"sub-02_ses-baseline_pet.json\"\n",
4130
")\n",
4231
"\n",
43-
"pet_dataset = pet.PET.load(pet_file, json_file)"
32+
"pet_dataset = PET.load(pet_file, json_file)"
4433
]
4534
},
4635
{
@@ -417,6 +406,8 @@
417406
}
418407
],
419408
"source": [
409+
"from nifreeze.model import PETModel\n",
410+
"\n",
420411
"model = PETModel(dataset=pet_dataset, timepoints=pet_dataset.midframe, xlim=7000)"
421412
]
422413
},
@@ -447,13 +438,15 @@
447438
"metadata": {},
448439
"outputs": [],
449440
"source": [
441+
"import nibabel as nb\n",
442+
"\n",
450443
"# before\n",
451-
"nifti_img_before = nib.Nifti1Image(predicted, pet_dataset.affine)\n",
444+
"nifti_img_before = nb.Nifti1Image(predicted, pet_dataset.affine)\n",
452445
"output_path_before = \"before_mc.nii\"\n",
453446
"nifti_img_before.to_filename(output_path_before)\n",
454447
"\n",
455448
"# after\n",
456-
"nifti_img_after = nib.Nifti1Image(data_test[0], pet_dataset.affine)\n",
449+
"nifti_img_after = nb.Nifti1Image(data_test[0], pet_dataset.affine)\n",
457450
"output_path_after = \"after_mc.nii\"\n",
458451
"nifti_img_after.to_filename(output_path_after)"
459452
]
@@ -2247,16 +2240,6 @@
22472240
")"
22482241
]
22492242
},
2250-
{
2251-
"cell_type": "code",
2252-
"execution_count": 12,
2253-
"id": "7c2c8811-d7ba-4ad1-8275-abd3b9ac3b10",
2254-
"metadata": {},
2255-
"outputs": [],
2256-
"source": [
2257-
"from nifreeze.estimator import PETMotionEstimator"
2258-
]
2259-
},
22602243
{
22612244
"cell_type": "code",
22622245
"execution_count": 13,
@@ -2272,6 +2255,8 @@
22722255
}
22732256
],
22742257
"source": [
2258+
"from nifreeze.estimator import PETMotionEstimator\n",
2259+
"\n",
22752260
"# Instantiate with a PETModel or appropriate model instance\n",
22762261
"model = PETModel(\n",
22772262
" dataset=pet_dataset, timepoints=pet_dataset.midframe, xlim=pet_dataset.total_duration\n",

0 commit comments

Comments
 (0)