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

Issue with tractography output files and BIDS format #1013

Closed
pierre-nedelec opened this issue Sep 1, 2023 · 5 comments
Closed

Issue with tractography output files and BIDS format #1013

pierre-nedelec opened this issue Sep 1, 2023 · 5 comments

Comments

@pierre-nedelec
Copy link
Collaborator

Two output tractography files are created each time, their path differing only with the addition of algo-AFQ_ for the one with classified bundles. This way of naming does not seem to be BIDS friendly. First algo is not a default recognized BIDS entity. This can be worked around for nor now like this. However a problem remains: if you try to access the file without the algo descriptor, you can't just using bids' layout.get() to access the one file that doesn't have "algo" setup.

from bids.layout import BIDSLayout, add_config_paths
from bids.exceptions import ConfigError
from pathlib import Path

root_dir = Path("to/your/BIDS/dataset")

try:
    add_config_paths(
        **{
            "bidsafq": "path/to/bidsafq.json"
        }
    )
except ConfigError as e:
    print(e)
except Exception as e:
    raise e

layout = BIDSLayout(root_dir)
layout.add_derivatives(root_dir / "derivatives", config=["bids", "bidsafq"])
params = {
    "subject": layout.get_subject()[0],
    "session": layout.get_sessions()[0],
    "extension": "trx",
    # "return_type": "filename",
    "suffix": "tractography",
    "algorithm": "AFQ",
}
layout.get(**params)
Attaching here again the json config
{
  "name": "bidsafq",
  "entities": [
    {
      "name": "algorithm",
      "pattern": "[_/\\\\]+algo-([a-zA-Z0-9]+)"
    }
  ]
}

With "algorithm": "AFQ", it returns one file. Without it, it returns both files. And I don't think there is way to access just the other one?

@pierre-nedelec
Copy link
Collaborator Author

pierre-nedelec commented Sep 6, 2023

A follow up issue here: if running pyAFQ after QSIprep (@mattcieslak), some entities are used twice, e.g. desc. Here's a path demonstrating this:

..._run-1_space-T1w_desc-preproc_dwi_space-RASMM_model-probCSD_algo-AFQ_desc-profiles_dwi.csv

(the suffix _dwi_ is also repeated btw)

This makes the layout.get(desc='profiles') unusable, as it only parses the first occurence.

One potential solution for pipelines developers could be for them to create their own Entities (see this pyBIDS issue)? Or should we stick to BIDS classic entities — in which case I'm not sure how to handle repeat entities?

@arokem
Copy link
Collaborator

arokem commented Sep 6, 2023

Thanks for raising this. Indeed, when we started formulating these file-names we did not follow the standard very closely. And the concatenation of file-names doesn't make much sense either - agreed about that.

I like the idea of creating custom entities here. This could serve as a basis for advocating for specific entities that would be included in the BIDS spec down the line. It will also probably make it easier to adopt/replace entities that supplant our development, once they are integrated upstream.

Do you want to give this a shot? For example, defining the algorithm entity?

@36000
Copy link
Collaborator

36000 commented Sep 6, 2023

Yes, I think defining a series of new entities makes sense here, though I wonder how this interacts with existing efforts in the BIDS communities to make standards for dMRI derivatives?

@arokem
Copy link
Collaborator

arokem commented Sep 6, 2023

I think that it would be helpful to these efforts, because it would provide a set of examples of entities and use-cases for these entities. Once things solidify upstream, we can hopefully more easily adopt the standard way of doing things.

@36000
Copy link
Collaborator

36000 commented Sep 21, 2023

I will make a PR to remove the additional suffix, and replacing desc- with something else and algo- with segalgo-. @pierre-nedelec , do u have code that we could use as a starting point for an example demonstrating the use entities?

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

No branches or pull requests

3 participants