Skip to content

revise nifti_read_example #152

Description

@wyli

Describe the bug
./modules/nifti_read_example.ipynb is broken due to the recent breaking changes: Project-MONAI/MONAI#1679

Running ./modules/nifti_read_example.ipynb
Checking PEP8 compliance...
Running notebook...

Executing:   0%|          | 0/15 [00:00<?, ?cell/s]
Executing:   7%|▋         | 1/15 [00:00<00:13,  1.00cell/s]
Executing:  20%|██        | 3/15 [00:04<00:15,  1.28s/cell]
Executing:  33%|███▎      | 5/15 [00:07<00:12,  1.27s/cell]
Executing:  60%|██████    | 9/15 [00:08<00:05,  1.05cell/s]
Executing:  73%|███████▎  | 11/15 [00:10<00:04,  1.04s/cell]
Executing:  87%|████████▋ | 13/15 [00:11<00:01,  1.25cell/s]
Executing:  87%|████████▋ | 13/15 [00:13<00:02,  1.02s/cell]
Traceback (most recent call last):
  File "/opt/conda/bin/papermill", line 8, in <module>
    sys.exit(papermill())
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/papermill/cli.py", line 250, in papermill
    execute_notebook(
  File "/opt/conda/lib/python3.8/site-packages/papermill/execute.py", line 122, in execute_notebook
    raise_for_execution_errors(nb, output_path)
  File "/opt/conda/lib/python3.8/site-packages/papermill/execute.py", line 234, in raise_for_execution_errors
    raise error
papermill.exceptions.PapermillExecutionError: 
---------------------------------------------------------------------------
Exception encountered at "In [6]":
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-e35c04338cac> in <module>
     10     ds, batch_size=10, num_workers=2, pin_memory=torch.cuda.is_available()
     11 )
---> 12 im, seg = first(loader)
     13 print(im.shape, seg.shape)

/__w/MONAI/MONAI/monai/utils/misc.py in first(iterable, default)
     69     Returns the first item in the given iterable or `default` if empty, meaningful mostly with 'for' expressions.
     70     """
---> 71     for i in iterable:
     72         return i
     73     return default

/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py in __next__(self)
    515             if self._sampler_iter is None:
    516                 self._reset()
--> 517             data = self._next_data()
    518             self._num_yielded += 1
    519             if self._dataset_kind == _DatasetKind.Iterable and \

/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py in _next_data(self)
   1197             else:
   1198                 del self._task_info[idx]
-> 1199                 return self._process_data(data)
   1200 
   1201     def _try_put_index(self):

/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py in _process_data(self, data)
   1223         self._try_put_index()
   1224         if isinstance(data, ExceptionWrapper):
-> 1225             data.reraise()
   1226         return data
   1227 

/opt/conda/lib/python3.8/site-packages/torch/_utils.py in reraise(self)
    427             # have message field
    428             raise self.exc_type(message=msg)
--> 429         raise self.exc_type(msg)
    430 
    431 

TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop
    data = fetcher.fetch(index)
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 28, in fetch
    data.append(next(self.dataset_iter))
  File "/__w/MONAI/MONAI/monai/data/grid_dataset.py", line 161, in __iter__
    for patch, slices, *_ in self.patch_iter(image):  # patch_iter to yield at least 2 items: patch, coords
TypeError: 'tuple' object is not callable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions