Created
          April 17, 2020 23:49 
        
      - 
      
- 
        Save oesteban/0c17459936deb18ac81377db4b4763c2 to your computer and use it in GitHub Desktop. 
    Check all nodes of a nipype 1.0 workflow and extract node name and duration
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | """Check node duration in a Nipype workflow.""" | |
| from pathlib import path | |
| import numpy as np | |
| import pandas as pd | |
| data = {'node': [], 'duration': []} | |
| for pth in Path().glob("**/report.rst"): | |
| rst = pth.read_text() | |
| info = [l.split(":")[-1].strip() for l in rst.splitlines() if "duration" in l or "Hierarchy" in l] | |
| data['node'].append(info[0]) | |
| try: | |
| data['duration'].append(float(info[1])) | |
| except IndexError: | |
| data['duration'].append(np.nan) | |
| df = pd.DataFrame(data) | |
| df[['node', 'duration']].sort_values(by='duration', ascending=False).to_csv('durations.tsv', sep='\t', index=None) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment