radio icon indicating copy to clipboard operation
radio copied to clipboard

Tutorial I: Error in preprocessing pipeline

Open ronykalfarisi opened this issue 5 years ago • 6 comments

Hi all, @roman-kh @akoryagin I cannot move forward pass tutorial I. The preprocessing pipeline worked when it only has load operation. But, when I chained it with resize operation, I found the following error. Please help, thanks Screenshot from 2019-05-29 16-40-57

The trace-back is the following...

AttributeError                            Traceback (most recent call last)
<ipython-input-9-fbc764c06c25> in <module>
----> 1 batch = (luna_dataset >> preprocessing).next_batch(batch_size=3, shuffle=False)

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/pipeline.py in next_batch(self, *args, **kwargs)
   1242                 self._lazy_run = args, kwargs
   1243                 self._batch_generator = self.gen_batch(*args, **kwargs)
-> 1244             batch_res = next(self._batch_generator)
   1245         else:
   1246             _kwargs = kwargs.copy()

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/pipeline.py in _gen_batch(self, *args, **kwargs)
   1212             for batch in batch_generator:
   1213                 try:
-> 1214                     batch_res = self.execute_for(batch)
   1215                 except SkipBatchException:
   1216                     pass

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/pipeline.py in execute_for(self, batch, new_loop)
    607             asyncio.set_event_loop(asyncio.new_event_loop())
    608         batch.pipeline = self
--> 609         batch_res = self._exec_all_actions(batch)
    610         batch_res.pipeline = self
    611         return batch_res

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/pipeline.py in _exec_all_actions(self, batch, action_list)
    579                     join_batches = None
    580 
--> 581                 batch = self._exec_one_action(batch, _action, _action_args, _action['kwargs'])
    582 
    583             batch.pipeline = self

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/pipeline.py in _exec_one_action(self, batch, action, args, kwargs)
    527                 batch.pipeline = self
    528                 action_method, _ = self._get_action_method(batch, action['name'])
--> 529                 batch = action_method(*args, **kwargs)
    530                 batch.pipeline = self
    531         return batch

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/decorators.py in _action_wrapper(action_self, *args, **kwargs)
     42                 action_self.pipeline.get_variable(_lock_name).acquire()
     43 
---> 44         _res = action_method(action_self, *args, **kwargs)
     45 
     46         if _use_lock is not None:

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/decorators.py in wrapped_method(self, *args, **kwargs)
    325                 x = wrap_with_async(self, args, kwargs)
    326             elif _target in ['threads', 't']:
--> 327                 x = wrap_with_threads(self, args, kwargs)
    328             elif _target in ['mpc', 'm']:
    329                 x = wrap_with_mpc(self, args, kwargs)

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/decorators.py in wrap_with_threads(self, args, kwargs)
    228                 cf.wait(futures, timeout=timeout, return_when=cf.ALL_COMPLETED)
    229 
--> 230             return _call_post_fn(self, post_fn, futures, args, full_kwargs)
    231 
    232         def wrap_with_mpc(self, args, kwargs):

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/decorators.py in _call_post_fn(self, post_fn, futures, args, kwargs)
    153                     traceback.print_tb(all_errors[0].__traceback__)
    154                 return self
--> 155             return post_fn(all_results, *args, **kwargs)
    156 
    157         def _prepare_args(self, args, kwargs):

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/preprocessing/ct_masked_batch.py in _post_rebuild(self, all_outputs, new_batch, **kwargs)
    974         batch._rescale_spacing()  # pylint: disable=protected-access
    975         if self.masks is not None:
--> 976             batch.create_mask()
    977         return batch
    978 

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/batchflow/batchflow/decorators.py in _action_wrapper(action_self, *args, **kwargs)
     42                 action_self.pipeline.get_variable(_lock_name).acquire()
     43 
---> 44         _res = action_method(action_self, *args, **kwargs)
     45 
     46         if _use_lock is not None:

/media/roguka/big_drive/workspace/tensorflow/venv/lib/python3.6/site-packages/radio/preprocessing/ct_masked_batch.py in create_mask(self, mode)
    502         self.masks = np.zeros_like(self.images)
    503 
--> 504         center_pix = np.abs(self.nodules.nodule_center -
    505                             self.nodules.origin) / self.nodules.spacing
    506         radius_pix = np.rint(self.nodules.nodule_size / self.nodules.spacing / 2)

AttributeError: 'NoneType' object has no attribute 'nodule_center'

ronykalfarisi avatar May 29 '19 20:05 ronykalfarisi

The case is having CTImagesMaskedBatch instead of CTImagesBatch in

from radio.batchflow import Dataset
from radio import CTImagesMaskedBatch
luna_dataset = Dataset(index=luna_index, batch_class=CTImagesMaskedBatch)

star-yar avatar Jul 17 '19 15:07 star-yar

@akoryagin @AlexeyKozhevin guys, please look at the issue.

roman-kh avatar Jul 17 '19 20:07 roman-kh

Hi @star-yar , I agree with you. However, I was using the tutorial jupyter notebook. So, I ran it as it was instructed in there. If I need to modify the tutorial codes, can you suggest me what needs to be changed? Thanks

ronykalfarisi avatar Jul 17 '19 21:07 ronykalfarisi

I have the same problem!could you give a way to it?

yuchen02 avatar Dec 22 '20 13:12 yuchen02

i'm having the same problem. Did anybody find a way out of it?

aggelos18 avatar Feb 17 '21 18:02 aggelos18

hi there, I also have the same problem. When CTImagesBatch is used, the resizing method works. Can anyone explain why using CTImagesMaskedBatch does not work?

lokeycookie avatar May 21 '21 01:05 lokeycookie