ERROR DETAIL: Preprocessor.__init__.<locals>.connect_error() takes 0 positional arguments but 1 was given
Hi all,
when I run the single case preprocessing exampel on MacOS 12.5.1 with an Apple M1, I get the error:
ERROR DETAIL: Preprocessor.__init__.<locals>.connect_error() takes 0 positional arguments but 1 was given
The full error trace is below.
Any idea what is going wrong?
Bests, Georg
File /opt/anaconda3/envs/brats_toolkit/lib/python3.10/site-packages/socketio/client.py:280, in Client.connect(self, url, headers, transports, namespaces, socketio_path)
279 try:
--> 280 self.eio.connect(url, headers=headers, transports=transports,
281 engineio_path=socketio_path)
282 except engineio.exceptions.ConnectionError as exc:
File /opt/anaconda3/envs/brats_toolkit/lib/python3.10/site-packages/engineio/client.py:194, in Client.connect(self, url, headers, transports, engineio_path)
193 self.queue = self.create_queue()
--> 194 return getattr(self, '_connect_' + self.transports[0])(
195 url, headers or {}, engineio_path)
File /opt/anaconda3/envs/brats_toolkit/lib/python3.10/site-packages/engineio/client.py:300, in Client._connect_polling(self, url, headers, engineio_path)
299 self._reset()
--> 300 raise exceptions.ConnectionError(
301 'Connection refused by the server')
302 if r.status_code < 200 or r.status_code >= 300:
ConnectionError: Connection refused by the server
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
File ~/projects/BraTS-Toolkit/0_preprocessing_single.py:17, in <module>
14 outputDir = "example_data/output_preprocessor_single/TCGA-DU-7294"
16 # execute it
---> 17 prep.single_preprocess(t1File=t1File, t1cFile=t1cFile, t2File=t2File, flaFile=flaFile,
18 outputFolder=outputDir, mode="cpu", confirm=True, skipUpdate=False, gpuid='0')
File ~/src/brats-toolkit/brats_toolkit/preprocessor.py:106, in Preprocessor.single_preprocess(self, t1File, t1cFile, t2File, flaFile, outputFolder, mode, confirm, skipUpdate, gpuid)
103 tempFiler(t2File, "t2", tempFolder)
104 tempFiler(flaFile, "fla", tempFolder)
--> 106 self.batch_preprocess(exam_import_folder=dockerFolder, exam_export_folder=dockerOutputFolder, mode=mode,
107 confirm=confirm, skipUpdate=skipUpdate, gpuid=gpuid)
File ~/src/brats-toolkit/brats_toolkit/preprocessor.py:127, in Preprocessor.batch_preprocess(self, exam_import_folder, exam_export_folder, dicom_import_folder, nifti_export_folder, mode, confirm, skipUpdate, gpuid)
124 # setup connection
125 # TODO do this in a more elegant way and somehow check whether docker is up and running before connect
126 self.sio.sleep(5) # wait 5 secs for docker to start
--> 127 self.connect_client()
128 self.sio.wait()
File ~/src/brats-toolkit/brats_toolkit/preprocessor.py:131, in Preprocessor.connect_client(self)
130 def connect_client(self):
--> 131 self.sio.connect('http://localhost:5000')
132 print('sid:', self.sio.sid)
File /opt/anaconda3/envs/brats_toolkit/lib/python3.10/site-packages/socketio/client.py:283, in Client.connect(self, url, headers, transports, namespaces, socketio_path)
280 self.eio.connect(url, headers=headers, transports=transports,
281 engineio_path=socketio_path)
282 except engineio.exceptions.ConnectionError as exc:
--> 283 self._trigger_event(
284 'connect_error', '/',
285 exc.args[1] if len(exc.args) > 1 else exc.args[0])
286 six.raise_from(exceptions.ConnectionError(exc.args[0]), None)
287 self.connected = True
File /opt/anaconda3/envs/brats_toolkit/lib/python3.10/site-packages/socketio/client.py:555, in Client._trigger_event(self, event, namespace, *args)
553 # first see if we have an explicit handler for the event
554 if namespace in self.handlers and event in self.handlers[namespace]:
--> 555 return self.handlers[namespace][event](*args)
557 # or else, forward the event to a namespace handler if one exists
558 elif namespace in self.namespace_handlers:
TypeError: Preprocessor.__init__.<locals>.connect_error() takes 0 positional arguments but 1 was given
Good morning, how do you run the example? Unfortunately, I don't have an M1 Mac yet to reproduce the issue.
Hi,
(1) I just installed docker on my M1, and followed the pip install instructions here in a newly created conda env. Then I run the preprocessing example.
(2) To debug the issue, I also run it on a linux machine with Ubuntu 22.04. There, I run part of the preprocessing but it also did not finish. It seems that one docker container was not pulled and installed, since I get this error message at the beginning of the script:
Error response from daemon: No such container: greedy_elephant
Have you seen that before?
For me running on linux is fine for now.
Georg
good evening
(1.) Sounds perfect so far; how do you run it? I should soon receive an M1 mbp for testing. Could you try a conda environment with python 3.8? I don't think this will be the issue, but let's see. I did most of the development in Python 3.6-3.8 days. It seems you are using 3.10 currently. (2.) Nothing to worry about, the frontend checks whether the backend is present, if not, you see this error msg, and it starts the backend, so this is normal output, even though I agree it sounds frightening. If the backend is not present on your system it should download it from docker hub.
(1) Installing via pip using python 3.8 does currently not work since simpleITK 2.1.1.1. is only available for python 3.10 as described in this issue
(2) I think the prepcoressing on Linux did not complete without errors. E.g. the output folder hdbet_brats-space is missing.
Is that a problem for the segmentor? Or can I simply use the robex_brats_space?
The preprocessing generated
|-- mask_robex_brats-space
| |-- TCGA-DU-7294_robex_mask_brats.nii.gz
| `-- TCGA-DU-7294_robex_mask_brats_transformation.log
|-- masks_robex_native-space
| |-- TCGA-DU-7294_robex_mask_native_fla.nii.gz
| |-- TCGA-DU-7294_robex_mask_native_fla_transformation.log
| |-- TCGA-DU-7294_robex_mask_native_t1c.nii.gz
| |-- TCGA-DU-7294_robex_mask_native_t1_creation.log
| |-- TCGA-DU-7294_robex_mask_native_t1c_transformation.log
| |-- TCGA-DU-7294_robex_mask_native_t1.nii.gz
| |-- TCGA-DU-7294_robex_mask_native_t2.nii.gz
| `-- TCGA-DU-7294_robex_mask_native_t2_transformation.log
|-- niftis_brats-space
| |-- TCGA-DU-7294_brats_fla.nii.gz
| |-- TCGA-DU-7294_brats_fla_transformation.log
| |-- TCGA-DU-7294_brats_t1c.nii.gz
| |-- TCGA-DU-7294_brats_t1c_transformation.log
| |-- TCGA-DU-7294_brats_t1.nii.gz
| |-- TCGA-DU-7294_brats_t1_transformation.log
| |-- TCGA-DU-7294_brats_t2.nii.gz
| `-- TCGA-DU-7294_brats_t2_transformation.log
|-- png_slices
| |-- TCGA-DU-7294_fla_slices.png
| |-- TCGA-DU-7294_T1c_slices.png
| |-- TCGA-DU-7294_T1_slices.png
| `-- TCGA-DU-7294_T2_slices.png
|-- registrations
| |-- TCGA-DU-7294_fla_to_t1_0GenericAffine.mat
| |-- TCGA-DU-7294_fla_to_t1_registration.log
| |-- TCGA-DU-7294_native_t1_to_brats_0GenericAffine.mat
| |-- TCGA-DU-7294_native_t1_to_brats_registration.log
| |-- TCGA-DU-7294_t1c_to_t1_0GenericAffine.mat
| |-- TCGA-DU-7294_t1c_to_t1_registration.log
| |-- TCGA-DU-7294_t2_to_t1_0GenericAffine.mat
| `-- TCGA-DU-7294_t2_to_t1_registration.log
|-- robex_brats-space
| |-- TCGA-DU-7294_robex_brats_fla.nii.gz
| |-- TCGA-DU-7294_robex_brats_t1c.nii.gz
| |-- TCGA-DU-7294_robex_brats_t1.nii.gz
| `-- TCGA-DU-7294_robex_brats_t2.nii.gz
`-- robex_native-space
|-- TCGA-DU-7294_robex_native_fla.nii.gz
|-- TCGA-DU-7294_robex_native_t1c.nii.gz
|-- TCGA-DU-7294_robex_native_t1.nii.gz
`-- TCGA-DU-7294_robex_native_t2.nii.gz
One more question: Is possible to run the brats_tools without CUDA GPU? The 1_segmentor example complains about not having a GPU.
Thanks this was the missing puzzle piece :) @LMZimmer please have a look at (1)
(2) Output looks good, what did you see in the console?
Assuming you used the parameters above the hdbet_brats-space folder is missing because you used cpu skull stripping (brain extraction). We offer Robex as a fallback for no GPU, low ram situations. You can use the robex file, the skull striping quality might be different and likely inferior compared to HD-BET.
One more question: Is possible to run the brats_tools without CUDA GPU? The 1_segmentor example complains about not having a GPU.
Preprocessing: GPU is optional (limitations with skull stripping as detailed above) Segmentation: Depends on the segmentation algorithm Fusion: No GPU required
closed until more information is provided.