Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typing related error in metadata embedding. #672

Closed
1 of 2 tasks
bpinsard opened this issue May 5, 2023 · 4 comments · Fixed by #673
Closed
1 of 2 tasks

typing related error in metadata embedding. #672

bpinsard opened this issue May 5, 2023 · 4 comments · Fixed by #673
Labels

Comments

@bpinsard
Copy link
Contributor

bpinsard commented May 5, 2023

Summary

Updating heudiconv from master branch, I have the following error showing up which seems related to #656 changes.

230505-14:27:39,460 nipype.workflow WARNING:                                                                                                              
         [Node] Error on "embedder" (/scratch/tmp/embedmetab5y9u753/embedder)                                                                             
Embedding failed: Exception raised while executing Node embedder.                                                                                         
                                                                                                                                                          
Traceback (most recent call last):                                                                                                                        
  File "/data/neuromod/virtualenvs/neuromod_data/lib/python3.7/site-packages/nipype/utils/functions.py", line 34, in create_function_from_source          
    exec(function_source, ns)                                                                                                                             
  File "<string>", line 4, in <module>                                                                                                                    
TypeError: unsupported operand type(s) for |: 'type' and 'type'                                                                                           
                                                                                                                                                          
The above exception was the direct cause of the following exception:                                                                                      
                                                                                                                                                          
Traceback (most recent call last):                                                                                                                        
  File "/data/neuromod/virtualenvs/neuromod_data/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 398, in run                            
    runtime = self._run_interface(runtime)                                                                                                                
  File "/data/neuromod/virtualenvs/neuromod_data/lib/python3.7/site-packages/nipype/interfaces/utility/wrappers.py", line 133, in _run_interface          
    self.inputs.function_str, self.imports                                                                                                                
  File "/data/neuromod/virtualenvs/neuromod_data/lib/python3.7/site-packages/nipype/utils/functions.py", line 44, in create_function_from_source          
    raise RuntimeError(msg) from e                                                                                                                        
RuntimeError: Error executing function                                                                                                                    
def embed_dicom_and_nifti_metadata(                                                                                                                       
    dcmfiles: List[str],                                                                                                                                  
    niftifile: str,                                                                                                                                       
    infofile: str | Path,                                                                                                                                 
    bids_info: Optional[Dict[str, Any]],                                                                                                                  
) -> None:                                                                                                                                                
    """Embed metadata from nifti (affine etc) and dicoms into infofile (json)                                                                             
                                                                                                                                                          
    `niftifile` should exist. Its affine's orientation information is used while                                                                          
    establishing new `NiftiImage` out of dicom stack and together with `bids_info`                                                                        
    (if provided) is dumped into json `infofile`                                                                                                          
                                                                                                                                                          
    Parameters                                                                                                                                            
    ----------                                                                                                                                            
    dcmfiles                                                                                                                                              
    niftifile                                                                                                                                             
    infofile                                                                                                                                              
    bids_info: dict                                                                                                                                       
      Additional metadata to be embedded. `infofile` is overwritten if exists,                                                                            
      so here you could pass some metadata which would overload (at the first                                                                             
      level of the dict structure, no recursive fancy updates) what is obtained                                                                           
      from nifti and dicoms                                                                                                                               
                                                                                                                                                          
    """                                                                                                                                                   
    # These imports need to be within the body of the function so that they                                                                               
    # will be available when executed by nipype:                                                                                                          
    import json                                                                                                                                           
    import os.path                                                                
...
...

Platform details:

Choose one:

  • Local environment: ubuntu-22.04 python3.7.16
  • Container
  • Heudiconv version:

0.5.3.post808+g6cc9f29

@jwodder
Copy link
Member

jwodder commented May 5, 2023

@bpinsard I believe #673 should fix this. Can you test it and see?

yarikoptic added a commit that referenced this issue May 5, 2023
Make an `embed_dicom_and_nifti_metadata()` annotation work on Python 3.7
@bpinsard
Copy link
Contributor Author

bpinsard commented May 5, 2023

Perfect, that' fixed on my side. Thanks!

@github-actions
Copy link

github-actions bot commented May 8, 2023

🚀 Issue was released in v0.13.0 🚀

@github-actions
Copy link

github-actions bot commented May 8, 2023

🚀 Issue was released in v0.13.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants