bids-apps / BrainSuite

BrainSuite's structural, diffusion, and functional MRI processing pipelines with QC functionalities.
Other
10 stars 4 forks source link

[BUG] OSError: Duplicate node name "BFP_rest" found. #8

Open suxpert opened 1 month ago

suxpert commented 1 month ago

What version of the bids app were you using?

bids/brainsuite:v23a

Describe your problem in detail.

I was trying run BrainSuite for resting-state analysis, and it failed to run.

My dataset is very simple:

$ tree bids
bids
├── ChangeLog
├── dataset_description.json
├── participants.json
├── participants.tsv
├── README.md
└── sub-0151
    └── ses-01
        ├── anat
        │   ├── sub-0151_ses-01_acq-highres_T1w.json
        │   └── sub-0151_ses-01_acq-highres_T1w.nii.gz
        ├── fmap
        │   ├── sub-0151_ses-01_magnitude1.json
        │   ├── sub-0151_ses-01_magnitude1.nii.gz
        │   ├── sub-0151_ses-01_magnitude2.json
        │   ├── sub-0151_ses-01_magnitude2.nii.gz
        │   ├── sub-0151_ses-01_phasediff.json
        │   └── sub-0151_ses-01_phasediff.nii.gz
        └── func
            ├── sub-0151_ses-01_task-rest_run-01_bold.json
            ├── sub-0151_ses-01_task-rest_run-01_bold.nii.gz
            ├── sub-0151_ses-01_task-rest_run-02_bold.json
            └── sub-0151_ses-01_task-rest_run-02_bold.nii.gz

6 directories, 17 files

I followed the instructions from here, with only input dataset be replaced. Then BrainSuite crashed with the following message:

Will be running the following fMRI with task-names ['rest']
No DWI images found. Therefore, not running BDP.

Running the following stages: ['CSE', 'SVREG', 'BFP', 'QC']

Traceback (most recent call last):
  File "/nipype/nipype/pipeline/engine/workflows.py", line 713, in _check_nodes
    this_node_lineage = node_lineage[idx]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/BrainSuite/run.py", line 509, in <module>
    main()
  File "/BrainSuite/run.py", line 391, in main
    dwis, funcs, subject_label, args)
  File "/BrainSuite/workflows/runWorkflow.py", line 126, in runWorkflow
    process.runWorkflow(subjectID, t1, outputdir, BFP)
  File "/BrainSuite/workflows/brainsuiteWorkflow.py", line 1371, in runWorkflow
    brainsuite_workflow.connect(BFPObjs[task], BFPoutput, BFPObjs[int(task+1)], 'dataSinkDelay')
  File "/nipype/nipype/pipeline/engine/workflows.py", line 178, in connect
    self._check_nodes(newnodes)
  File "/nipype/nipype/pipeline/engine/workflows.py", line 715, in _check_nodes
    raise IOError('Duplicate node name "%s" found.' % node.name)
OSError: Duplicate node name "BFP_rest" found.

What command did you run?

docker run -it --rm                           \
    -v $BIDS:/data:ro                         \
    -v $BIDS/derivatives/bsapps-v23a:/out     \
    bids/brainsuite:v23a /data /out participant

Describe what you expected.

I would expect BrainSuite can deal with such a simple dataset with default config without any problem.

yeunkim commented 1 month ago

Hi,

Thanks for thorough bug report. This problem can occur when there are multiple runs of the fMRI file of the same task name but just one run of T1w file. There are some issues that can arise in the output names in these situations.

For now, could you try renaming fMRI task names to be different? (i.e., sub-0151_ses-01_task-restA_run-01_bold.nii.gz and sub-0151_ses-01_task-restB_run-02_bold.nii.gz)

Also, I would suggest using the --ignore_suffix acq flag since these tokens are not present in the other modalities' file names.

Thank you, Yeun

suxpert commented 1 month ago

I can confirm that if I leave only one of the resting state func files, BrainSuite works without error. But in my case, if the tasks are splitted into multiple runs, how could I do the 2nd level analysis that combine results from multiple runs, or perform a group analysis correctly? Rename the tasks makes it difficult to match them.

yeunkim commented 1 month ago

Would you be running our BrainSuite BIDS App for group-level analysis? Or which statistical tests were you planning on running?

suxpert commented 1 month ago

I'm not familar with BrainSuite, but I guess it can run both the subject-level and group-level analysis, right? I was trying to run some analysis on resting state fMRI data, so both subject-level and group-level are needed. In my case, the non-cannonical point is that I have two short runs for one participant, since I have to rename one of them (according to your previous solution), how could I obtain the group-level that considered both runs for all subject, when I finished the subject-level analysis with each run have a different name?

yeunkim commented 1 month ago

Yes, you can run the group-level analysis with our BrainSuite BIDS App. We haven't yet implemented our package to handle multiple runs of the same task fMRI, because we haven't sorted out how to handle the issue of multiple T1w and task fMRI runs.

You can try running the group-level analysis by defining the subject IDs in the demographics TSV file to contain the task token (e.g., sub-${ID}_task-restA) in the participant_id column and setting the file_ext field in the modelspec.json file (sample file is provided in the templates directory) as _bold.32k.GOrd.filt.mat. This field specifies the constant file suffix of the *.mat file. Let me know if this works for you.