|
24 | 24 | "outputs": [], |
25 | 25 | "source": [ |
26 | 26 | "import nest_asyncio\n", |
| 27 | + "\n", |
27 | 28 | "nest_asyncio.apply()" |
28 | 29 | ] |
29 | 30 | }, |
|
201 | 202 | "nifti_files = [Nifti1.sample(nifti_dir, seed=i) for i in range(10)]\n", |
202 | 203 | "\n", |
203 | 204 | "VOX_SIZES = [\n", |
204 | | - " (0.5, 0.5, 0.5),\n", |
205 | | - " (0.25, 0.25, 0.25),\n", |
206 | | - " (0.1, 0.1, 0.1),\n", |
207 | | - " (0.35, 0.35, 0.35),\n", |
208 | | - " (0.1, 0.1, 0.1),\n", |
209 | | - " (0.5, 0.5, 0.5),\n", |
210 | | - " (0.25, 0.25, 0.25),\n", |
211 | | - " (0.2, 0.2, 0.2),\n", |
212 | | - " (0.35, 0.35, 0.35),\n", |
213 | | - " (0.1, 0.1, 0.1),\n", |
214 | | - " ]\n", |
| 205 | + " (0.5, 0.5, 0.5),\n", |
| 206 | + " (0.25, 0.25, 0.25),\n", |
| 207 | + " (0.1, 0.1, 0.1),\n", |
| 208 | + " (0.35, 0.35, 0.35),\n", |
| 209 | + " (0.1, 0.1, 0.1),\n", |
| 210 | + " (0.5, 0.5, 0.5),\n", |
| 211 | + " (0.25, 0.25, 0.25),\n", |
| 212 | + " (0.2, 0.2, 0.2),\n", |
| 213 | + " (0.35, 0.35, 0.35),\n", |
| 214 | + " (0.1, 0.1, 0.1),\n", |
| 215 | + "]\n", |
215 | 216 | "\n", |
216 | 217 | "mrgrid_varying_vox = MrGrid(operation=\"regrid\").split(\n", |
217 | 218 | " (\"in_file\", \"voxel\"),\n", |
|
300 | 301 | "with submitter:\n", |
301 | 302 | " result4 = submitter(mrgrid_varying_vox4)\n", |
302 | 303 | "\n", |
303 | | - "# The cache directory for the new run is different \n", |
| 304 | + "# The cache directory for the new run is different\n", |
304 | 305 | "assert result4.output_dir != result1.output_dir" |
305 | 306 | ] |
306 | 307 | }, |
|
331 | 332 | "\n", |
332 | 333 | "# Instantiate the task definition, \"splitting\" over all NIfTI files in the test directory\n", |
333 | 334 | "# by splitting the \"input\" input field over all files in the directory\n", |
334 | | - "mrgrid = MrGrid(in_file=nifti_file, operation=\"regrid\", voxel=(0.5,0.5,0.5))\n", |
| 335 | + "mrgrid = MrGrid(in_file=nifti_file, operation=\"regrid\", voxel=(0.5, 0.5, 0.5))\n", |
335 | 336 | "\n", |
336 | 337 | "# Run the task to resample all NIfTI files\n", |
337 | 338 | "outputs = mrgrid(environment=Docker(image=\"mrtrix3/mrtrix3\", tag=\"latest\"))\n", |
|
375 | 376 | "import os\n", |
376 | 377 | "import platform\n", |
377 | 378 | "\n", |
| 379 | + "\n", |
378 | 380 | "def notify_task_completion(task: Task, result: Result):\n", |
379 | 381 | " # Print a message to the terminal\n", |
380 | 382 | " print(f\"Task completed! Results are stored in {str(task.output_dir)!r}\")\n", |
381 | 383 | "\n", |
382 | 384 | " # Platform-specific notifications\n", |
383 | 385 | " if platform.system() == \"Darwin\": # macOS\n", |
384 | | - " os.system('osascript -e \\'display notification \"Task has completed successfully!\" with title \"Task Notification\"\\'')\n", |
| 386 | + " os.system(\n", |
| 387 | + " 'osascript -e \\'display notification \"Task has completed successfully!\" '\n", |
| 388 | + " 'with title \"Task Notification\"\\''\n", |
| 389 | + " )\n", |
385 | 390 | " elif platform.system() == \"Linux\": # Linux\n", |
386 | 391 | " os.system('notify-send \"Task Notification\" \"Task has completed successfully!\"')\n", |
387 | 392 | " elif platform.system() == \"Windows\": # Windows\n", |
388 | 393 | " os.system('msg * \"Task has completed successfully!\"')\n", |
389 | 394 | "\n", |
| 395 | + "\n", |
390 | 396 | "# Run the task to resample all NIfTI files\n", |
391 | | - "outputs = mrgrid(hooks=TaskHooks(post_run=notify_task_completion), cache_dir=tempfile.mkdtemp())\n", |
| 397 | + "outputs = mrgrid(\n", |
| 398 | + " hooks=TaskHooks(post_run=notify_task_completion), cache_dir=tempfile.mkdtemp()\n", |
| 399 | + ")\n", |
392 | 400 | "\n", |
393 | 401 | "# Print the locations of the output files\n", |
394 | 402 | "pprint(outputs.out_file)" |
|
0 commit comments