|
33 | 33 | "from pprint import pprint\n", |
34 | 34 | "import json\n", |
35 | 35 | "\n", |
36 | | - "JSON_CONTENTS = {'a': True, 'b': 'two', 'c': 3, 'd': [7, 0.55, 6]}\n", |
| 36 | + "JSON_CONTENTS = {\"a\": True, \"b\": \"two\", \"c\": 3, \"d\": [7, 0.55, 6]}\n", |
37 | 37 | "\n", |
38 | 38 | "test_dir = Path(mkdtemp())\n", |
39 | 39 | "json_file = test_dir / \"test.json\"\n", |
|
78 | 78 | "outputs": [], |
79 | 79 | "source": [ |
80 | 80 | "import nest_asyncio\n", |
| 81 | + "\n", |
81 | 82 | "nest_asyncio.apply()" |
82 | 83 | ] |
83 | 84 | }, |
|
154 | 155 | "\n", |
155 | 156 | "# Instantiate the task definition, \"splitting\" over all NIfTI files in the test directory\n", |
156 | 157 | "# by splitting the \"input\" input field over all files in the directory\n", |
157 | | - "mrgrid = MrGrid(operation=\"regrid\", voxel=(0.5,0.5,0.5)).split(in_file=nifti_dir.iterdir())\n", |
| 158 | + "mrgrid = MrGrid(operation=\"regrid\", voxel=(0.5, 0.5, 0.5)).split(\n", |
| 159 | + " in_file=nifti_dir.iterdir()\n", |
| 160 | + ")\n", |
158 | 161 | "\n", |
159 | 162 | "# Run the task to resample all NIfTI files\n", |
160 | 163 | "outputs = mrgrid()\n", |
|
235 | 238 | "source": [ |
236 | 239 | "from pydra.tasks.mrtrix3.v3_0 import MrGrid\n", |
237 | 240 | "\n", |
238 | | - "if __name__ == \"__main__\": # <-- Add this block to allow the script to imported by subprocesses\n", |
239 | | - " mrgrid = MrGrid(operation=\"regrid\", voxel=(0.5,0.5,0.5)).split(in_file=nifti_dir.iterdir())\n", |
| 241 | + "if (\n", |
| 242 | + " __name__ == \"__main__\"\n", |
| 243 | + "): # <-- Add this block to allow the script to imported by subprocesses\n", |
| 244 | + " mrgrid = MrGrid(operation=\"regrid\", voxel=(0.5, 0.5, 0.5)).split(\n", |
| 245 | + " in_file=nifti_dir.iterdir()\n", |
| 246 | + " )\n", |
240 | 247 | " outputs = mrgrid(worker=\"cf\", n_procs=4) # <-- Select the \"cf\" worker here\n", |
241 | 248 | " print(\"\\n\".join(str(p) for p in outputs.out_file))" |
242 | 249 | ] |
|
301 | 308 | "my_cache_dir = Path(\"~/new-pydra-cache\").expanduser()\n", |
302 | 309 | "my_cache_dir.mkdir(exist_ok=True)\n", |
303 | 310 | "\n", |
304 | | - "outputs = mrgrid(\n", |
305 | | - " cache_dir=my_cache_dir,\n", |
306 | | - " cache_locations=[default_run_cache_dir]\n", |
307 | | - ")\n", |
| 311 | + "outputs = mrgrid(cache_dir=my_cache_dir, cache_locations=[default_run_cache_dir])\n", |
308 | 312 | "\n", |
309 | 313 | "print(outputs)" |
310 | 314 | ] |
|
0 commit comments