How pyAFQ uses BIDS#

The pyAFQ API relies heavily on the Brain Imaging Data Standard (BIDS), a widely used standard for organizing and describing neuroimaging data. This means that the software assumes that its inputs are organized according to the BIDS specification and its outputs conform where possible with BIDS.

Note

Derivatives of processing diffusion MRI are not currently fully described in the existing BIDS specification, but describing these is part of an ongoing effort. Wherever possible, we conform with the draft implementation of the BIDS DWI derivatives available here

In this example, we will explore the use of BIDS in pyAFQ and see how BIDS allows us to extend and provide flexibility to the users of the software.

import os
import os.path as op

import AFQ.api.bundle_dict as abd
from AFQ.api.group import GroupAFQ, get_afq_bids_entities_fname
import AFQ.data.fetch as afd
To interact with and query BIDS datasets, we use

pyBIDS, which we import here:

import bids
from bids.layout import BIDSLayout

We start with some example data. The data we will use here is generated from the Stanford HARDI dataset. The call below fetches this dataset and organized it within the ~/AFQ_data folder in the BIDS format.

afd.organize_stanford_data(clear_previous_afq="all")

After doing that, we should have a folder that looks like this:

stanford_hardi
├── dataset_description.json
└── derivatives
├── freesurfer
│   ├── dataset_description.json
│   └── sub-01
│   └── ses-01
│   └── anat
│   ├── sub-01_ses-01_T1w.nii.gz
│   └── sub-01_ses-01_seg.nii.gz
└── vistasoft
├── dataset_description.json
└── sub-01
└── ses-01
└── dwi
├── sub-01_ses-01_dwi.bvals
├── sub-01_ses-01_dwi.bvecs
└── sub-01_ses-01_dwi.nii.gz

The top level directory (stanford_hardi) is our overall BIDS dataset folder. In many cases, this folder will include folders with raw data for each subject in the dataset. In this case, we do not include the raw data folders and only have the outputs of pipelines that were used to preprocess the data (e.g., correct the data for subject motion, eddy currents, and so forth). In general, only the preprocessed diffusion data is required for pyAFQ to run. See the “Organizing your data” section of the documentation for more details. In this case, one folder contains derivative of the Freesurfer software and another folder contains the DWI data that has been preprocessed with the Vistasoft software. pyAFQ provides facilities to segment tractography results obtained using other software as well. For example, we often use qsiprep to preprocess our data and reconstruct tractographies with software such as MRTRIX. Here, we will demonstrate how to use these reconstructions in the pyAFQ segmentation and tractometry pipeline We fetch this data and add it as a separate pipeline The following code will download a previously-created tractography and organize it by adding it to the BIDS dataset folder and renaming them to be BIDS-compliant (e.g., sub-01_ses_01_dwi_tractography.trk).

afd.fetch_stanford_hardi_tractography()

bids_path = op.join(op.expanduser('~'), 'AFQ_data', 'stanford_hardi')
tractography_path = op.join(bids_path, 'derivatives', 'my_tractography')
sub_path = op.join(tractography_path, 'sub-01', 'ses-01', 'dwi')

os.makedirs(sub_path, exist_ok=True)
os.rename(
    op.join(
        op.expanduser('~'),
        'AFQ_data',
        'stanford_hardi_tractography',
        'full_segmented_cleaned_tractography.trk'),
    op.join(
        sub_path,
        'sub-01_ses-01-dwi_tractography.trk'))

afd.to_bids_description(
    tractography_path,
    **{"Name": "my_tractography",
       "PipelineDescription": {"Name": "my_tractography"},
       "GeneratedBy": [{"Name": "my_tractography"}]})
  0%|          | 0/11337 [00:00<?, ? MB/s]
  0%|          | 4/11337 [00:00<06:46, 27.89 MB/s]
  0%|          | 15/11337 [00:00<03:17, 57.39 MB/s]
  1%|          | 66/11337 [00:00<00:57, 196.43 MB/s]
  2%|▏         | 263/11337 [00:00<00:15, 712.82 MB/s]
  5%|▌         | 589/11337 [00:00<00:07, 1472.67 MB/s]
  7%|▋         | 819/11337 [00:00<00:06, 1667.10 MB/s]
 10%|▉         | 1083/11337 [00:00<00:05, 1949.24 MB/s]
 12%|█▏        | 1387/11337 [00:00<00:04, 2202.00 MB/s]
 14%|█▍        | 1617/11337 [00:01<00:04, 2186.01 MB/s]
 17%|█▋        | 1929/11337 [00:01<00:03, 2428.58 MB/s]
 19%|█▉        | 2178/11337 [00:01<00:03, 2409.79 MB/s]
 22%|██▏       | 2470/11337 [00:01<00:03, 2503.30 MB/s]
 24%|██▍       | 2723/11337 [00:01<00:03, 2487.22 MB/s]
 27%|██▋       | 3039/11337 [00:01<00:03, 2627.16 MB/s]
 29%|██▉       | 3303/11337 [00:01<00:03, 2588.92 MB/s]
 32%|███▏      | 3599/11337 [00:01<00:02, 2664.46 MB/s]
 34%|███▍      | 3867/11337 [00:01<00:02, 2612.02 MB/s]
 36%|███▋      | 4129/11337 [00:02<00:02, 2610.94 MB/s]
 39%|███▉      | 4399/11337 [00:02<00:02, 2603.92 MB/s]
 41%|████      | 4660/11337 [00:02<00:02, 2571.77 MB/s]
 44%|████▍     | 4965/11337 [00:02<00:02, 2654.58 MB/s]
 46%|████▌     | 5231/11337 [00:02<00:02, 2575.06 MB/s]
 49%|████▉     | 5539/11337 [00:02<00:02, 2717.98 MB/s]
 51%|█████▏    | 5812/11337 [00:02<00:02, 2571.37 MB/s]
 54%|█████▍    | 6130/11337 [00:02<00:02, 2594.68 MB/s]
 56%|█████▋    | 6403/11337 [00:02<00:01, 2631.65 MB/s]
 59%|█████▉    | 6696/11337 [00:02<00:01, 2629.34 MB/s]
 61%|██████▏   | 6960/11337 [00:03<00:01, 2616.37 MB/s]
 64%|██████▍   | 7233/11337 [00:03<00:01, 2648.53 MB/s]
 66%|██████▌   | 7499/11337 [00:03<00:01, 2519.85 MB/s]
 69%|██████▊   | 7768/11337 [00:03<00:01, 2551.23 MB/s]
 71%|███████   | 8050/11337 [00:03<00:01, 2557.55 MB/s]
 73%|███████▎  | 8331/11337 [00:03<00:01, 2596.11 MB/s]
 76%|███████▌  | 8617/11337 [00:03<00:01, 2616.65 MB/s]
 78%|███████▊  | 8880/11337 [00:03<00:00, 2565.83 MB/s]
 81%|████████  | 9164/11337 [00:03<00:00, 2602.44 MB/s]
 83%|████████▎ | 9425/11337 [00:04<00:00, 2590.75 MB/s]
 86%|████████▌ | 9720/11337 [00:04<00:00, 2694.01 MB/s]
 88%|████████▊ | 9990/11337 [00:04<00:00, 2617.73 MB/s]
 90%|█████████ | 10253/11337 [00:04<00:00, 2613.84 MB/s]
 93%|█████████▎| 10519/11337 [00:04<00:00, 2627.13 MB/s]
 95%|█████████▌| 10785/11337 [00:04<00:00, 2622.83 MB/s]
 98%|█████████▊| 11071/11337 [00:04<00:00, 2658.83 MB/s]
100%|██████████| 11337/11337 [00:04<00:00, 2371.34 MB/s]

  0%|          | 0/14 [00:00<?, ? MB/s]
 29%|██▊       | 4/14 [00:00<00:00, 26.52 MB/s]
100%|██████████| 14/14 [00:00<00:00, 62.97 MB/s]

  0%|          | 0/1037 [00:00<?, ? MB/s]
  0%|          | 4/1037 [00:00<00:36, 28.35 MB/s]
  1%|▏         | 15/1037 [00:00<00:18, 56.40 MB/s]
  6%|▌         | 63/1037 [00:00<00:05, 183.78 MB/s]
 13%|█▎        | 133/1037 [00:00<00:02, 302.23 MB/s]
 36%|███▌      | 372/1037 [00:00<00:00, 764.34 MB/s]
 52%|█████▏    | 538/1037 [00:00<00:00, 889.91 MB/s]
 62%|██████▏   | 641/1037 [00:01<00:00, 871.16 MB/s]
 70%|███████   | 727/1037 [00:01<00:00, 768.81 MB/s]
 78%|███████▊  | 804/1037 [00:01<00:00, 607.57 MB/s]
 84%|████████▍ | 869/1037 [00:01<00:00, 485.53 MB/s]
 89%|████████▉ | 923/1037 [00:01<00:00, 363.47 MB/s]
 93%|█████████▎| 966/1037 [00:02<00:00, 226.14 MB/s]
 96%|█████████▋| 999/1037 [00:02<00:00, 153.98 MB/s]
 99%|█████████▊| 1024/1037 [00:03<00:00, 119.43 MB/s]
100%|██████████| 1037/1037 [00:03<00:00, 289.58 MB/s]

After we do that, our dataset folder should look like this:

stanford_hardi
├── dataset_description.json
└── derivatives
├── freesurfer
│   ├── dataset_description.json
│   └── sub-01
│   └── ses-01
│   └── anat
│   ├── sub-01_ses-01_T1w.nii.gz
│   └── sub-01_ses-01_seg.nii.gz
├── my_tractography
| ├── dataset_description.json
│   └── sub-01
│   └── ses-01
│   └── dwi
│   └── sub-01_ses-01-dwi_tractography.trk
└── vistasoft
├── dataset_description.json
└── sub-01
└── ses-01
└── dwi
├── sub-01_ses-01_dwi.bvals
├── sub-01_ses-01_dwi.bvecs
└── sub-01_ses-01_dwi.nii.gz

To explore the layout of these derivatives, we will initialize a BIDSLayout class instance to help us see what is in this dataset

layout = bids.BIDSLayout(bids_path, derivatives=True)

Because there is no raw data in this BIDS layout (only derivatives), pybids will report that there are no subjects and sessions:

print(layout)
BIDS Layout: ...runner/AFQ_data/stanford_hardi | Subjects: 0 | Sessions: 0 | Runs: 0

But a query on the derivatives will reveal the different derivatives that are stored here:

print(layout.derivatives)
{'derivatives/freesurfer': BIDS Layout: ...d_hardi/derivatives/freesurfer | Subjects: 1 | Sessions: 1 | Runs: 0, 'derivatives/vistasoft': BIDS Layout: ...rd_hardi/derivatives/vistasoft | Subjects: 1 | Sessions: 1 | Runs: 0, 'derivatives/recobundles': BIDS Layout: ..._hardi/derivatives/recobundles | Subjects: 1 | Sessions: 1 | Runs: 0, 'derivatives/my_tractography': BIDS Layout: ...di/derivatives/my_tractography | Subjects: 1 | Sessions: 1 | Runs: 0}

We can use a bids.BIDSValidator object to make sure that the files within our data set are BIDS-compliant. For example, we can extract the tractography derivatives part of our layout using:

my_tractography = layout.derivatives["my_tractography"]

This variable is also a BIDS layout object. This object has a get method, which allows us to query and find specific items within the layout. For example, we can ask for files that have a suffix consistent with tractography results:

tractography_files = my_tractography.get(suffix='tractography')

Or ask for files that have a .trk extension:

tractography_files = my_tractography.get(extension='.trk')

In this case, both of these would produce the same result.

tractography_file = tractography_files[0]
print(tractography_file)
<BIDSFile filename='/home/runner/AFQ_data/stanford_hardi/derivatives/my_tractography/sub-01/ses-01/dwi/sub-01_ses-01-dwi_tractography.trk'>

We can also get some more structured information about this file:

print(tractography_file.get_entities())
{'datatype': 'dwi', 'extension': '.trk', 'session': '01', 'subject': '01', 'suffix': 'tractography'}

We can use a bids.BIDSValidator class instance to validate that this file is compliant with the specification. Note that the validator requires that the filename be provided relative to the root of the BIDS dataset, so we have to split the string that contains the full path of the tractography to extract only the part that is relative to the root of the entire BIDS layout object:

tractography_full_path = tractography_file.path
tractography_relative_path = tractography_full_path.split(layout.root)[-1]

validator = bids.BIDSValidator()
print(validator.is_bids(tractography_relative_path))
True

Next, we specify the information we need to define the bundles that we are interested in segmenting. In this case, we are going to use a list of bundle names for the bundle info. These names refer to bundles for which we already have clear definitions of the information needed to segment them (e.g., waypoint ROIs and probability maps). For an example that includes custom definition of bundle info, see the plot_callosal_tract_profile example.

bundle_info = abd.default18_bd()[
    "Left Superior Longitudinal",
    "Right Superior Longitudinal",
    "Left Arcuate",
    "Right Arcuate",
    "Left Corticospinal",
    "Right Corticospinal",
    "Forceps Minor"]

Now, we can define our GroupAFQ object, pointing to the derivatives of the ‘my_tractography’ pipeline as inputs. This is done by setting the import_tract key-word argument. We pass the bundle_info defined above. We also point to the preprocessed data that is in a ‘dmriprep’ pipeline. Note that the pipeline name is not necessarily the name of the folder it is in; the pipeline name is defined in each pipeline’s dataset_description.json. These data were preprocessed with ‘vistasoft’, so this is the pipeline we’ll point to If we were using ‘qsiprep’, this is where we would pass that string instead. If we did that, AFQ would look for a derivatives folder called ‘stanford_hardi/derivatives/qsiprep’ and find the preprocessed DWI data within it. Finally, to speed things up a bit, we also sub-sample the provided tractography. This is done by defining the segmentation_params dictionary input. To sub-sample to 10,000 streamlines, we define ‘nb_streamlines’ = 10000.

my_afq = GroupAFQ(
    bids_path,
    preproc_pipeline='vistasoft',
    bundle_info=bundle_info,
    import_tract={
        "suffix": "tractography",
        "scope": "my_tractography"
    },
    segmentation_params={'nb_streamlines': 10000})

Finally, to run the segmentation and extract tract profiles, we call The export_all method. This creates all of the derivative outputs of AFQ within the ‘stanford_hardi/derivatives/afq’ folder.

my_afq.export_all()
  0%|          | 0/179864.0 [00:00<?, ?it/s]
  0%|          | 277/179864.0 [00:00<01:04, 2769.53it/s]
  0%|          | 666/179864.0 [00:00<00:52, 3423.77it/s]
  1%|          | 1077/179864.0 [00:00<00:47, 3734.86it/s]
  1%|          | 1470/179864.0 [00:00<00:46, 3808.30it/s]
  1%|          | 1874/179864.0 [00:00<00:45, 3891.19it/s]
  1%|▏         | 2286/179864.0 [00:00<00:44, 3968.03it/s]
  2%|▏         | 2702/179864.0 [00:00<00:43, 4030.14it/s]
  2%|▏         | 3112/179864.0 [00:00<00:43, 4051.01it/s]
  2%|▏         | 3534/179864.0 [00:00<00:42, 4101.83it/s]
  2%|▏         | 3956/179864.0 [00:01<00:42, 4137.40it/s]
  2%|▏         | 4372/179864.0 [00:01<00:42, 4143.56it/s]
  3%|▎         | 4799/179864.0 [00:01<00:41, 4180.45it/s]
  3%|▎         | 5227/179864.0 [00:01<00:41, 4208.56it/s]
  3%|▎         | 5648/179864.0 [00:01<00:42, 4124.90it/s]
  3%|▎         | 6068/179864.0 [00:01<00:41, 4145.65it/s]
  4%|▎         | 6502/179864.0 [00:01<00:41, 4201.20it/s]
  4%|▍         | 6936/179864.0 [00:01<00:40, 4242.01it/s]
  4%|▍         | 7361/179864.0 [00:01<00:40, 4236.59it/s]
  4%|▍         | 7807/179864.0 [00:01<00:40, 4299.80it/s]
  5%|▍         | 8249/179864.0 [00:02<00:39, 4335.73it/s]
  5%|▍         | 8683/179864.0 [00:02<00:39, 4329.05it/s]
  5%|▌         | 9116/179864.0 [00:02<00:39, 4274.33it/s]
  5%|▌         | 9557/179864.0 [00:02<00:39, 4313.29it/s]
  6%|▌         | 9989/179864.0 [00:02<00:39, 4262.83it/s]
  6%|▌         | 10416/179864.0 [00:02<00:41, 4121.12it/s]
  6%|▌         | 10830/179864.0 [00:02<00:41, 4120.21it/s]
  6%|▋         | 11256/179864.0 [00:02<00:40, 4159.81it/s]
  7%|▋         | 11705/179864.0 [00:02<00:39, 4256.07it/s]
  7%|▋         | 12151/179864.0 [00:02<00:38, 4316.22it/s]
  7%|▋         | 12592/179864.0 [00:03<00:38, 4340.70it/s]
  7%|▋         | 13027/179864.0 [00:03<00:38, 4300.34it/s]
  7%|▋         | 13459/179864.0 [00:03<00:38, 4304.68it/s]
  8%|▊         | 13909/179864.0 [00:03<00:38, 4360.72it/s]
  8%|▊         | 14367/179864.0 [00:03<00:37, 4425.33it/s]
  8%|▊         | 14817/179864.0 [00:03<00:37, 4444.82it/s]
  8%|▊         | 15262/179864.0 [00:03<00:37, 4424.30it/s]
  9%|▊         | 15705/179864.0 [00:03<00:37, 4341.92it/s]
  9%|▉         | 16170/179864.0 [00:03<00:36, 4430.14it/s]
  9%|▉         | 16630/179864.0 [00:03<00:36, 4480.05it/s]
 10%|▉         | 17089/179864.0 [00:04<00:36, 4511.21it/s]
 10%|▉         | 17541/179864.0 [00:04<00:36, 4483.32it/s]
 10%|█         | 17990/179864.0 [00:04<00:36, 4417.84it/s]
 10%|█         | 18433/179864.0 [00:04<00:36, 4401.72it/s]
 11%|█         | 18894/179864.0 [00:04<00:36, 4462.10it/s]
 11%|█         | 19341/179864.0 [00:04<00:36, 4443.97it/s]
 11%|█         | 19799/179864.0 [00:04<00:35, 4482.64it/s]
 11%|█▏        | 20248/179864.0 [00:04<00:35, 4454.56it/s]
 12%|█▏        | 20694/179864.0 [00:04<00:36, 4411.50it/s]
 12%|█▏        | 21142/179864.0 [00:04<00:35, 4430.75it/s]
 12%|█▏        | 21609/179864.0 [00:05<00:35, 4499.71it/s]
 12%|█▏        | 22061/179864.0 [00:05<00:35, 4503.65it/s]
 13%|█▎        | 22520/179864.0 [00:05<00:34, 4527.75it/s]
 13%|█▎        | 22973/179864.0 [00:05<00:34, 4513.45it/s]
 13%|█▎        | 23425/179864.0 [00:05<00:35, 4426.53it/s]
 13%|█▎        | 23889/179864.0 [00:05<00:34, 4489.27it/s]
 14%|█▎        | 24352/179864.0 [00:05<00:34, 4527.71it/s]
 14%|█▍        | 24816/179864.0 [00:05<00:34, 4559.36it/s]
 14%|█▍        | 25273/179864.0 [00:05<00:34, 4542.71it/s]
 14%|█▍        | 25730/179864.0 [00:05<00:33, 4547.78it/s]
 15%|█▍        | 26185/179864.0 [00:06<00:34, 4489.11it/s]
 15%|█▍        | 26638/179864.0 [00:06<00:34, 4500.88it/s]
 15%|█▌        | 27108/179864.0 [00:06<00:33, 4557.51it/s]
 15%|█▌        | 27581/179864.0 [00:06<00:33, 4608.34it/s]
 16%|█▌        | 28045/179864.0 [00:06<00:32, 4616.34it/s]
 16%|█▌        | 28507/179864.0 [00:06<00:32, 4604.35it/s]
 16%|█▌        | 28968/179864.0 [00:06<00:33, 4507.53it/s]
 16%|█▋        | 29420/179864.0 [00:06<00:33, 4437.88it/s]
 17%|█▋        | 29876/179864.0 [00:06<00:33, 4469.84it/s]
 17%|█▋        | 30348/179864.0 [00:06<00:32, 4541.52it/s]
 17%|█▋        | 30815/179864.0 [00:07<00:32, 4579.56it/s]
 17%|█▋        | 31282/179864.0 [00:07<00:32, 4604.86it/s]
 18%|█▊        | 31743/179864.0 [00:07<00:32, 4562.96it/s]
 18%|█▊        | 32200/179864.0 [00:07<00:32, 4536.31it/s]
 18%|█▊        | 32654/179864.0 [00:07<00:32, 4463.58it/s]
 18%|█▊        | 33101/179864.0 [00:07<00:32, 4459.14it/s]
 19%|█▊        | 33559/179864.0 [00:07<00:32, 4493.28it/s]
 19%|█▉        | 34021/179864.0 [00:07<00:32, 4527.94it/s]
 19%|█▉        | 34487/179864.0 [00:07<00:31, 4565.24it/s]
 19%|█▉        | 34946/179864.0 [00:08<00:31, 4572.41it/s]
 20%|█▉        | 35404/179864.0 [00:08<00:31, 4561.93it/s]
 20%|█▉        | 35861/179864.0 [00:08<00:32, 4495.37it/s]
 20%|██        | 36311/179864.0 [00:08<00:32, 4480.45it/s]
 20%|██        | 36783/179864.0 [00:08<00:31, 4549.46it/s]
 21%|██        | 37257/179864.0 [00:08<00:30, 4605.45it/s]
 21%|██        | 37728/179864.0 [00:08<00:30, 4634.32it/s]
 21%|██        | 38192/179864.0 [00:09<01:05, 2174.78it/s]
 21%|██▏       | 38642/179864.0 [00:09<00:55, 2562.27it/s]
 22%|██▏       | 39075/179864.0 [00:09<00:48, 2901.45it/s]
 22%|██▏       | 39505/179864.0 [00:09<00:43, 3202.75it/s]
 22%|██▏       | 39957/179864.0 [00:09<00:39, 3512.62it/s]
 22%|██▏       | 40437/179864.0 [00:09<00:36, 3835.71it/s]
 23%|██▎       | 40909/179864.0 [00:09<00:34, 4068.65it/s]
 23%|██▎       | 41364/179864.0 [00:09<00:32, 4200.19it/s]
 23%|██▎       | 41824/179864.0 [00:09<00:32, 4312.05it/s]
 24%|██▎       | 42278/179864.0 [00:09<00:31, 4308.91it/s]
 24%|██▍       | 42739/179864.0 [00:10<00:31, 4395.25it/s]
 24%|██▍       | 43201/179864.0 [00:10<00:30, 4459.11it/s]
 24%|██▍       | 43686/179864.0 [00:10<00:29, 4571.38it/s]
 25%|██▍       | 44183/179864.0 [00:10<00:28, 4688.62it/s]
 25%|██▍       | 44657/179864.0 [00:10<00:29, 4659.39it/s]
 25%|██▌       | 45126/179864.0 [00:10<00:28, 4656.91it/s]
 25%|██▌       | 45594/179864.0 [00:10<00:29, 4545.32it/s]
 26%|██▌       | 46051/179864.0 [00:10<00:29, 4530.46it/s]
 26%|██▌       | 46522/179864.0 [00:10<00:29, 4582.57it/s]
 26%|██▌       | 47010/179864.0 [00:11<00:28, 4668.95it/s]
 26%|██▋       | 47514/179864.0 [00:11<00:27, 4774.12it/s]
 27%|██▋       | 47993/179864.0 [00:11<00:27, 4731.10it/s]
 27%|██▋       | 48467/179864.0 [00:11<00:28, 4691.50it/s]
 27%|██▋       | 48937/179864.0 [00:11<00:28, 4617.20it/s]
 27%|██▋       | 49400/179864.0 [00:11<00:28, 4590.07it/s]
 28%|██▊       | 49860/179864.0 [00:11<00:28, 4578.79it/s]
 28%|██▊       | 50353/179864.0 [00:11<00:27, 4679.83it/s]
 28%|██▊       | 50836/179864.0 [00:11<00:27, 4720.95it/s]
 29%|██▊       | 51309/179864.0 [00:11<00:27, 4669.09it/s]
 29%|██▉       | 51777/179864.0 [00:12<00:27, 4655.61it/s]
 29%|██▉       | 52244/179864.0 [00:12<00:27, 4659.70it/s]
 29%|██▉       | 52711/179864.0 [00:12<00:27, 4613.84it/s]
 30%|██▉       | 53173/179864.0 [00:12<00:27, 4525.87it/s]
 30%|██▉       | 53649/179864.0 [00:12<00:27, 4593.76it/s]
 30%|███       | 54133/179864.0 [00:12<00:26, 4665.92it/s]
 30%|███       | 54616/179864.0 [00:12<00:26, 4713.20it/s]
 31%|███       | 55088/179864.0 [00:12<00:26, 4714.02it/s]
 31%|███       | 55560/179864.0 [00:12<00:27, 4573.64it/s]
 31%|███       | 56019/179864.0 [00:12<00:27, 4510.21it/s]
 31%|███▏      | 56475/179864.0 [00:13<00:27, 4521.71it/s]
 32%|███▏      | 56934/179864.0 [00:13<00:27, 4541.15it/s]
 32%|███▏      | 57436/179864.0 [00:13<00:26, 4681.15it/s]
 32%|███▏      | 57923/179864.0 [00:13<00:25, 4734.87it/s]
 32%|███▏      | 58415/179864.0 [00:13<00:25, 4788.30it/s]
 33%|███▎      | 58899/179864.0 [00:13<00:25, 4801.85it/s]
 33%|███▎      | 59380/179864.0 [00:13<00:25, 4786.37it/s]
 33%|███▎      | 59859/179864.0 [00:13<00:25, 4682.12it/s]
 34%|███▎      | 60328/179864.0 [00:13<00:26, 4537.47it/s]
 34%|███▍      | 60823/179864.0 [00:13<00:25, 4655.98it/s]
 34%|███▍      | 61327/179864.0 [00:14<00:24, 4768.19it/s]
 34%|███▍      | 61828/179864.0 [00:14<00:24, 4837.07it/s]
 35%|███▍      | 62313/179864.0 [00:14<00:24, 4781.31it/s]
 35%|███▍      | 62800/179864.0 [00:14<00:24, 4802.35it/s]
 35%|███▌      | 63281/179864.0 [00:14<00:24, 4676.32it/s]
 35%|███▌      | 63750/179864.0 [00:14<00:25, 4608.15it/s]
 36%|███▌      | 64241/179864.0 [00:14<00:24, 4693.63it/s]
 36%|███▌      | 64725/179864.0 [00:14<00:24, 4733.75it/s]
 36%|███▋      | 65224/179864.0 [00:14<00:23, 4807.82it/s]
 37%|███▋      | 65706/179864.0 [00:14<00:23, 4799.00it/s]
 37%|███▋      | 66195/179864.0 [00:15<00:23, 4825.15it/s]
 37%|███▋      | 66678/179864.0 [00:15<00:24, 4685.12it/s]
 37%|███▋      | 67148/179864.0 [00:15<00:24, 4617.56it/s]
 38%|███▊      | 67611/179864.0 [00:15<00:24, 4602.71it/s]
 38%|███▊      | 68090/179864.0 [00:15<00:24, 4656.92it/s]
 38%|███▊      | 68569/179864.0 [00:15<00:23, 4694.76it/s]
 38%|███▊      | 69051/179864.0 [00:15<00:23, 4731.33it/s]
 39%|███▊      | 69533/179864.0 [00:15<00:23, 4756.24it/s]
 39%|███▉      | 70009/179864.0 [00:15<00:23, 4680.83it/s]
 39%|███▉      | 70478/179864.0 [00:16<00:23, 4586.15it/s]
 39%|███▉      | 70941/179864.0 [00:16<00:23, 4596.26it/s]
 40%|███▉      | 71419/179864.0 [00:16<00:23, 4648.41it/s]
 40%|███▉      | 71899/179864.0 [00:16<00:23, 4691.16it/s]
 40%|████      | 72370/179864.0 [00:16<00:22, 4695.99it/s]
 40%|████      | 72840/179864.0 [00:16<00:22, 4686.71it/s]
 41%|████      | 73309/179864.0 [00:16<00:23, 4594.71it/s]
 41%|████      | 73769/179864.0 [00:16<00:23, 4512.02it/s]
 41%|████▏     | 74221/179864.0 [00:16<00:23, 4464.08it/s]
 42%|████▏     | 74681/179864.0 [00:16<00:23, 4501.66it/s]
 42%|████▏     | 75146/179864.0 [00:17<00:23, 4542.72it/s]
 42%|████▏     | 75622/179864.0 [00:17<00:22, 4605.13it/s]
 42%|████▏     | 76084/179864.0 [00:17<00:22, 4607.01it/s]
 43%|████▎     | 76545/179864.0 [00:17<00:22, 4593.75it/s]
 43%|████▎     | 77005/179864.0 [00:17<00:22, 4490.42it/s]
 43%|████▎     | 77455/179864.0 [00:17<00:23, 4415.18it/s]
 43%|████▎     | 77902/179864.0 [00:17<00:23, 4428.92it/s]
 44%|████▎     | 78382/179864.0 [00:17<00:22, 4537.66it/s]
 44%|████▍     | 78845/179864.0 [00:17<00:22, 4562.88it/s]
 44%|████▍     | 79311/179864.0 [00:17<00:21, 4589.16it/s]
 44%|████▍     | 79771/179864.0 [00:18<00:22, 4533.91it/s]
 45%|████▍     | 80225/179864.0 [00:18<00:22, 4484.19it/s]
 45%|████▍     | 80674/179864.0 [00:18<00:22, 4442.70it/s]
 45%|████▌     | 81119/179864.0 [00:18<00:22, 4380.59it/s]
 45%|████▌     | 81570/179864.0 [00:18<00:22, 4416.56it/s]
 46%|████▌     | 82032/179864.0 [00:18<00:21, 4475.02it/s]
 46%|████▌     | 82490/179864.0 [00:18<00:21, 4505.52it/s]
 46%|████▌     | 82941/179864.0 [00:18<00:21, 4495.31it/s]
 46%|████▋     | 83391/179864.0 [00:18<00:21, 4412.02it/s]
 47%|████▋     | 83839/179864.0 [00:18<00:21, 4431.88it/s]
 47%|████▋     | 84283/179864.0 [00:19<00:21, 4432.78it/s]
 47%|████▋     | 84727/179864.0 [00:19<00:21, 4423.15it/s]
 47%|████▋     | 85187/179864.0 [00:19<00:21, 4475.36it/s]
 48%|████▊     | 85650/179864.0 [00:19<00:20, 4518.89it/s]
 48%|████▊     | 86103/179864.0 [00:19<00:20, 4506.77it/s]
 48%|████▊     | 86554/179864.0 [00:19<00:20, 4497.56it/s]
 48%|████▊     | 87004/179864.0 [00:19<00:21, 4389.00it/s]
 49%|████▊     | 87444/179864.0 [00:19<00:21, 4386.92it/s]
 49%|████▉     | 87884/179864.0 [00:19<00:21, 4348.40it/s]
 49%|████▉     | 88345/179864.0 [00:20<00:20, 4425.31it/s]
 49%|████▉     | 88814/179864.0 [00:20<00:20, 4501.56it/s]
 50%|████▉     | 89294/179864.0 [00:20<00:19, 4589.72it/s]
 50%|████▉     | 89770/179864.0 [00:20<00:19, 4638.94it/s]
 50%|█████     | 90235/179864.0 [00:20<00:19, 4591.58it/s]
 50%|█████     | 90695/179864.0 [00:20<00:19, 4498.85it/s]
 51%|█████     | 91146/179864.0 [00:20<00:19, 4459.05it/s]
 51%|█████     | 91593/179864.0 [00:20<00:20, 4376.94it/s]
 51%|█████     | 92054/179864.0 [00:20<00:19, 4444.56it/s]
 51%|█████▏    | 92524/179864.0 [00:20<00:19, 4519.27it/s]
 52%|█████▏    | 92992/179864.0 [00:21<00:19, 4564.05it/s]
 52%|█████▏    | 93457/179864.0 [00:21<00:18, 4587.14it/s]
 52%|█████▏    | 93917/179864.0 [00:21<00:18, 4565.04it/s]
 52%|█████▏    | 94374/179864.0 [00:21<00:18, 4550.25it/s]
 53%|█████▎    | 94830/179864.0 [00:21<00:18, 4481.27it/s]
 53%|█████▎    | 95279/179864.0 [00:21<00:19, 4443.42it/s]
 53%|█████▎    | 95749/179864.0 [00:21<00:18, 4517.89it/s]
 53%|█████▎    | 96212/179864.0 [00:21<00:18, 4548.66it/s]
 54%|█████▎    | 96669/179864.0 [00:21<00:18, 4554.88it/s]
 54%|█████▍    | 97125/179864.0 [00:21<00:18, 4509.98it/s]
 54%|█████▍    | 97577/179864.0 [00:22<00:18, 4416.09it/s]
 54%|█████▍    | 98020/179864.0 [00:22<00:18, 4398.58it/s]
 55%|█████▍    | 98461/179864.0 [00:22<00:18, 4357.69it/s]
 55%|█████▍    | 98904/179864.0 [00:22<00:18, 4377.73it/s]
 55%|█████▌    | 99373/179864.0 [00:22<00:18, 4469.25it/s]
 56%|█████▌    | 99839/179864.0 [00:22<00:17, 4525.69it/s]
 56%|█████▌    | 100299/179864.0 [00:22<00:17, 4545.94it/s]
 56%|█████▌    | 100755/179864.0 [00:22<00:17, 4550.12it/s]
 56%|█████▋    | 101211/179864.0 [00:22<00:17, 4397.59it/s]
 57%|█████▋    | 101661/179864.0 [00:22<00:17, 4424.77it/s]
 57%|█████▋    | 102105/179864.0 [00:23<00:17, 4425.11it/s]
 57%|█████▋    | 102572/179864.0 [00:23<00:17, 4493.87it/s]
 57%|█████▋    | 103022/179864.0 [00:23<00:17, 4486.42it/s]
 58%|█████▊    | 103491/179864.0 [00:23<00:16, 4544.79it/s]
 58%|█████▊    | 103955/179864.0 [00:23<00:16, 4572.46it/s]
 58%|█████▊    | 104415/179864.0 [00:23<00:16, 4579.03it/s]
 58%|█████▊    | 104874/179864.0 [00:23<00:16, 4476.64it/s]
 59%|█████▊    | 105323/179864.0 [00:23<00:16, 4479.59it/s]
 59%|█████▉    | 105776/179864.0 [00:23<00:16, 4491.71it/s]
 59%|█████▉    | 106248/179864.0 [00:23<00:16, 4558.39it/s]
 59%|█████▉    | 106724/179864.0 [00:24<00:15, 4617.41it/s]
 60%|█████▉    | 107193/179864.0 [00:24<00:15, 4638.20it/s]
 60%|█████▉    | 107657/179864.0 [00:24<00:15, 4620.44it/s]
 60%|██████    | 108120/179864.0 [00:24<00:15, 4607.20it/s]
 60%|██████    | 108581/179864.0 [00:24<00:15, 4549.52it/s]
 61%|██████    | 109045/179864.0 [00:24<00:15, 4574.66it/s]
 61%|██████    | 109516/179864.0 [00:24<00:15, 4613.33it/s]
 61%|██████    | 110001/179864.0 [00:24<00:14, 4683.82it/s]
 61%|██████▏   | 110481/179864.0 [00:24<00:14, 4716.92it/s]
 62%|██████▏   | 110955/179864.0 [00:24<00:14, 4723.08it/s]
 62%|██████▏   | 111436/179864.0 [00:25<00:14, 4747.44it/s]
 62%|██████▏   | 111911/179864.0 [00:25<00:14, 4691.23it/s]
 62%|██████▏   | 112381/179864.0 [00:25<00:14, 4600.56it/s]
 63%|██████▎   | 112848/179864.0 [00:25<00:14, 4618.56it/s]
 63%|██████▎   | 113326/179864.0 [00:25<00:14, 4665.10it/s]
 63%|██████▎   | 113816/179864.0 [00:25<00:13, 4732.99it/s]
 64%|██████▎   | 114297/179864.0 [00:25<00:13, 4754.32it/s]
 64%|██████▍   | 114773/179864.0 [00:25<00:13, 4712.92it/s]
 64%|██████▍   | 115245/179864.0 [00:25<00:13, 4695.42it/s]
 64%|██████▍   | 115715/179864.0 [00:26<00:13, 4650.95it/s]
 65%|██████▍   | 116181/179864.0 [00:26<00:13, 4652.69it/s]
 65%|██████▍   | 116664/179864.0 [00:26<00:13, 4703.17it/s]
 65%|██████▌   | 117148/179864.0 [00:26<00:13, 4741.51it/s]
 65%|██████▌   | 117623/179864.0 [00:26<00:13, 4735.15it/s]
 66%|██████▌   | 118109/179864.0 [00:26<00:12, 4771.67it/s]
 66%|██████▌   | 118593/179864.0 [00:26<00:12, 4788.68it/s]
 66%|██████▌   | 119072/179864.0 [00:26<00:12, 4718.37it/s]
 66%|██████▋   | 119545/179864.0 [00:26<00:12, 4703.99it/s]
 67%|██████▋   | 120044/179864.0 [00:26<00:12, 4787.33it/s]
 67%|██████▋   | 120534/179864.0 [00:27<00:12, 4820.30it/s]
 67%|██████▋   | 121017/179864.0 [00:27<00:12, 4798.12it/s]
 68%|██████▊   | 121498/179864.0 [00:27<00:12, 4800.98it/s]
 68%|██████▊   | 121989/179864.0 [00:27<00:11, 4832.96it/s]
 68%|██████▊   | 122473/179864.0 [00:27<00:12, 4708.79it/s]
 68%|██████▊   | 122945/179864.0 [00:27<00:12, 4695.50it/s]
 69%|██████▊   | 123433/179864.0 [00:27<00:11, 4748.54it/s]
 69%|██████▉   | 123922/179864.0 [00:27<00:11, 4789.82it/s]
 69%|██████▉   | 124403/179864.0 [00:27<00:11, 4794.66it/s]
 69%|██████▉   | 124883/179864.0 [00:27<00:11, 4790.46it/s]
 70%|██████▉   | 125363/179864.0 [00:28<00:11, 4780.85it/s]
 70%|██████▉   | 125842/179864.0 [00:28<00:11, 4693.23it/s]
 70%|███████   | 126312/179864.0 [00:28<00:11, 4667.51it/s]
 70%|███████   | 126780/179864.0 [00:28<00:11, 4617.58it/s]
 71%|███████   | 127263/179864.0 [00:28<00:11, 4679.91it/s]
 71%|███████   | 127745/179864.0 [00:28<00:11, 4720.49it/s]
 71%|███████▏  | 128218/179864.0 [00:28<00:11, 4686.02it/s]
 72%|███████▏  | 128687/179864.0 [00:28<00:10, 4682.02it/s]
 72%|███████▏  | 129156/179864.0 [00:28<00:10, 4621.08it/s]
 72%|███████▏  | 129619/179864.0 [00:28<00:10, 4587.91it/s]
 72%|███████▏  | 130100/179864.0 [00:29<00:10, 4652.01it/s]
 73%|███████▎  | 130569/179864.0 [00:29<00:10, 4663.16it/s]
 73%|███████▎  | 131054/179864.0 [00:29<00:10, 4717.64it/s]
 73%|███████▎  | 131526/179864.0 [00:29<00:10, 4699.13it/s]
 73%|███████▎  | 131997/179864.0 [00:29<00:10, 4690.69it/s]
 74%|███████▎  | 132467/179864.0 [00:29<00:10, 4576.24it/s]
 74%|███████▍  | 132926/179864.0 [00:29<00:10, 4494.49it/s]
 74%|███████▍  | 133377/179864.0 [00:29<00:10, 4496.67it/s]
 74%|███████▍  | 133847/179864.0 [00:29<00:10, 4555.69it/s]
 75%|███████▍  | 134315/179864.0 [00:29<00:09, 4591.25it/s]
 75%|███████▍  | 134775/179864.0 [00:30<00:09, 4584.55it/s]
 75%|███████▌  | 135247/179864.0 [00:30<00:09, 4621.47it/s]
 75%|███████▌  | 135710/179864.0 [00:30<00:09, 4611.06it/s]
 76%|███████▌  | 136172/179864.0 [00:30<00:09, 4503.22it/s]
 76%|███████▌  | 136623/179864.0 [00:30<00:09, 4485.44it/s]
 76%|███████▌  | 137093/179864.0 [00:30<00:09, 4547.11it/s]
 76%|███████▋  | 137577/179864.0 [00:30<00:09, 4630.33it/s]
 77%|███████▋  | 138041/179864.0 [00:30<00:09, 4624.17it/s]
 77%|███████▋  | 138506/179864.0 [00:30<00:08, 4631.83it/s]
 77%|███████▋  | 138970/179864.0 [00:30<00:08, 4566.81it/s]
 78%|███████▊  | 139427/179864.0 [00:31<00:09, 4439.89it/s]
 78%|███████▊  | 139872/179864.0 [00:31<00:09, 4420.59it/s]
 78%|███████▊  | 140352/179864.0 [00:31<00:08, 4531.63it/s]
 78%|███████▊  | 140834/179864.0 [00:31<00:08, 4615.61it/s]
 79%|███████▊  | 141297/179864.0 [00:31<00:08, 4619.77it/s]
 79%|███████▉  | 141760/179864.0 [00:31<00:08, 4606.44it/s]
 79%|███████▉  | 142221/179864.0 [00:31<00:08, 4546.21it/s]
 79%|███████▉  | 142676/179864.0 [00:31<00:08, 4474.07it/s]
 80%|███████▉  | 143140/179864.0 [00:31<00:08, 4522.09it/s]
 80%|███████▉  | 143593/179864.0 [00:32<00:14, 2464.10it/s]
 80%|████████  | 144082/179864.0 [00:32<00:12, 2916.95it/s]
 80%|████████  | 144563/179864.0 [00:32<00:10, 3315.22it/s]
 81%|████████  | 145020/179864.0 [00:32<00:09, 3603.86it/s]
 81%|████████  | 145461/179864.0 [00:32<00:09, 3802.75it/s]
 81%|████████  | 145921/179864.0 [00:32<00:08, 4010.80it/s]
 81%|████████▏ | 146410/179864.0 [00:32<00:07, 4245.55it/s]
 82%|████████▏ | 146882/179864.0 [00:32<00:07, 4378.08it/s]
 82%|████████▏ | 147364/179864.0 [00:33<00:07, 4503.77it/s]
 82%|████████▏ | 147831/179864.0 [00:33<00:07, 4548.96it/s]
 82%|████████▏ | 148298/179864.0 [00:33<00:06, 4560.48it/s]
 83%|████████▎ | 148763/179864.0 [00:33<00:06, 4490.13it/s]
 83%|████████▎ | 149241/179864.0 [00:33<00:06, 4573.47it/s]
 83%|████████▎ | 149705/179864.0 [00:33<00:06, 4590.48it/s]
 83%|████████▎ | 150180/179864.0 [00:33<00:06, 4636.95it/s]
 84%|████████▍ | 150646/179864.0 [00:33<00:06, 4639.87it/s]
 84%|████████▍ | 151112/179864.0 [00:33<00:06, 4590.67it/s]
 84%|████████▍ | 151573/179864.0 [00:34<00:06, 4575.12it/s]
 85%|████████▍ | 152032/179864.0 [00:34<00:06, 4555.52it/s]
 85%|████████▍ | 152489/179864.0 [00:34<00:06, 4557.05it/s]
 85%|████████▌ | 152953/179864.0 [00:34<00:05, 4580.46it/s]
 85%|████████▌ | 153415/179864.0 [00:34<00:05, 4588.31it/s]
 86%|████████▌ | 153875/179864.0 [00:34<00:05, 4537.30it/s]
 86%|████████▌ | 154329/179864.0 [00:34<00:05, 4480.67it/s]
 86%|████████▌ | 154778/179864.0 [00:34<00:05, 4347.42it/s]
 86%|████████▋ | 155231/179864.0 [00:34<00:05, 4399.51it/s]
 87%|████████▋ | 155698/179864.0 [00:34<00:05, 4478.72it/s]
 87%|████████▋ | 156150/179864.0 [00:35<00:05, 4488.88it/s]
 87%|████████▋ | 156600/179864.0 [00:35<00:05, 4486.47it/s]
 87%|████████▋ | 157050/179864.0 [00:35<00:05, 4470.36it/s]
 88%|████████▊ | 157498/179864.0 [00:35<00:05, 4371.96it/s]
 88%|████████▊ | 157947/179864.0 [00:35<00:04, 4403.80it/s]
 88%|████████▊ | 158420/179864.0 [00:35<00:04, 4497.90it/s]
 88%|████████▊ | 158895/179864.0 [00:35<00:04, 4570.80it/s]
 89%|████████▊ | 159353/179864.0 [00:35<00:04, 4380.48it/s]
 89%|████████▉ | 159793/179864.0 [00:35<00:04, 4358.50it/s]
 89%|████████▉ | 160231/179864.0 [00:35<00:04, 4261.54it/s]
 89%|████████▉ | 160678/179864.0 [00:36<00:04, 4321.48it/s]
 90%|████████▉ | 161146/179864.0 [00:36<00:04, 4421.87it/s]
 90%|████████▉ | 161598/179864.0 [00:36<00:04, 4447.13it/s]
 90%|█████████ | 162044/179864.0 [00:36<00:04, 4446.69it/s]
 90%|█████████ | 162490/179864.0 [00:36<00:03, 4362.63it/s]
 91%|█████████ | 162927/179864.0 [00:36<00:03, 4358.17it/s]
 91%|█████████ | 163368/179864.0 [00:36<00:03, 4372.65it/s]
 91%|█████████ | 163809/179864.0 [00:36<00:03, 4381.76it/s]
 91%|█████████▏| 164254/179864.0 [00:36<00:03, 4401.98it/s]
 92%|█████████▏| 164695/179864.0 [00:36<00:03, 4363.90it/s]
 92%|█████████▏| 165132/179864.0 [00:37<00:03, 4352.84it/s]
 92%|█████████▏| 165581/179864.0 [00:37<00:03, 4392.06it/s]
 92%|█████████▏| 166033/179864.0 [00:37<00:03, 4429.47it/s]
 93%|█████████▎| 166481/179864.0 [00:37<00:03, 4440.92it/s]
 93%|█████████▎| 166926/179864.0 [00:37<00:02, 4396.40it/s]
 93%|█████████▎| 167366/179864.0 [00:37<00:02, 4382.56it/s]
 93%|█████████▎| 167827/179864.0 [00:37<00:02, 4447.82it/s]
 94%|█████████▎| 168272/179864.0 [00:37<00:02, 4258.68it/s]
 94%|█████████▍| 168700/179864.0 [00:37<00:02, 4257.82it/s]
 94%|█████████▍| 169127/179864.0 [00:37<00:02, 4256.21it/s]
 94%|█████████▍| 169561/179864.0 [00:38<00:02, 4280.80it/s]
 95%|█████████▍| 170015/179864.0 [00:38<00:02, 4357.22it/s]
 95%|█████████▍| 170455/179864.0 [00:38<00:02, 4368.02it/s]
 95%|█████████▌| 170901/179864.0 [00:38<00:02, 4393.76it/s]
 95%|█████████▌| 171341/179864.0 [00:38<00:01, 4331.78it/s]
 96%|█████████▌| 171786/179864.0 [00:38<00:01, 4364.10it/s]
 96%|█████████▌| 172223/179864.0 [00:38<00:01, 4313.72it/s]
 96%|█████████▌| 172655/179864.0 [00:38<00:01, 4206.69it/s]
 96%|█████████▌| 173077/179864.0 [00:38<00:01, 4089.57it/s]
 96%|█████████▋| 173512/179864.0 [00:39<00:01, 4164.07it/s]
 97%|█████████▋| 173946/179864.0 [00:39<00:01, 4214.64it/s]
 97%|█████████▋| 174380/179864.0 [00:39<00:01, 4248.47it/s]
 97%|█████████▋| 174819/179864.0 [00:39<00:01, 4290.27it/s]
 97%|█████████▋| 175256/179864.0 [00:39<00:01, 4312.17it/s]
 98%|█████████▊| 175698/179864.0 [00:39<00:00, 4341.00it/s]
 98%|█████████▊| 176133/179864.0 [00:39<00:00, 4292.53it/s]
 98%|█████████▊| 176563/179864.0 [00:39<00:00, 4275.31it/s]
 98%|█████████▊| 177008/179864.0 [00:39<00:00, 4326.55it/s]
 99%|█████████▊| 177441/179864.0 [00:39<00:00, 4178.39it/s]
 99%|█████████▉| 177903/179864.0 [00:40<00:00, 4304.60it/s]
 99%|█████████▉| 178335/179864.0 [00:40<00:00, 4292.28it/s]
 99%|█████████▉| 178799/179864.0 [00:40<00:00, 4394.45it/s]
100%|█████████▉| 179260/179864.0 [00:40<00:00, 4457.43it/s]
100%|█████████▉| 179748/179864.0 [00:40<00:00, 4582.30it/s]
100%|██████████| 179864/179864.0 [00:40<00:00, 4443.51it/s]
Optimizing level 2 [max iter: 10000]
Optimizing level 1 [max iter: 1000]
Optimizing level 0 [max iter: 100]
Optimizing level 2 [max iter: 10000]
Optimizing level 1 [max iter: 1000]
Optimizing level 0 [max iter: 100]
Optimizing level 2 [max iter: 10000]
Optimizing level 1 [max iter: 1000]
Optimizing level 0 [max iter: 100]

  0%|          | 0/7 [00:00<?, ?it/s]
 71%|███████▏  | 5/7 [00:00<00:00, 45.67it/s]
100%|██████████| 7/7 [00:00<00:00, 45.10it/s]

  0%|          | 0/7 [00:00<?, ?it/s]
 57%|█████▋    | 4/7 [00:00<00:00, 36.08it/s]
100%|██████████| 7/7 [00:00<00:00, 39.55it/s]

A few common issues that can hinder BIDS from working properly are:

  1. Faulty dataset_description.json file. You need to make sure that the file contains the right names for the pipeline. See above for an example of that.

  2. File naming convention doesn’t uniquely identify file with bids filters.

The outputs of AFQ are also BIDS compatible. However, we use some custom entities, which need to be loaded. Here we demonstrate how to load the afq entities with get_afq_bids_entities_fname() and then show all files with the key-value pair recogmethod-AFQ

layout = BIDSLayout(bids_path)
layout.add_derivatives(
    f'{bids_path}/derivatives/afq',
    config=['bids', 'derivatives', get_afq_bids_entities_fname()])
print(layout.get(recogmethod="AFQ", return_type="filename"))
['/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-ForcepsMinor_tractography.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-ForcepsMinor_tractography.trk', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftArcuate_tractography.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftArcuate_tractography.trk', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftCorticospinal_tractography.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftCorticospinal_tractography.trk', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftSuperiorLongitudinal_tractography.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftSuperiorLongitudinal_tractography.trk', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightArcuate_tractography.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightArcuate_tractography.trk', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightCorticospinal_tractography.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightCorticospinal_tractography.trk', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightSuperiorLongitudinal_tractography.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightSuperiorLongitudinal_tractography.trk', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-ForcepsMinorviz_dwi', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-medianBundleLengths_dwi.csv', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-medianBundleLengths_dwi.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-profiles_dwi.csv', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-profiles_dwi.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-slCount_dwi.csv', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-slCount_dwi.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-viz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-viz_dwi.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_tractography.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_tractography.trk', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/tract_profile_plots/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_model-dtifa_desc-vizprofile_dwi.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/tract_profile_plots/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_model-dtifa_desc-vizprofile_dwi.png', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/tract_profile_plots/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_model-dtifa_desc-vizprofile_dwi.svg', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/tract_profile_plots/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_model-dtimd_desc-vizprofile_dwi.json', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/tract_profile_plots/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_model-dtimd_desc-vizprofile_dwi.png', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/tract_profile_plots/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_model-dtimd_desc-vizprofile_dwi.svg', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-ForcepsMinorviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftArcuateviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftCorticospinalviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftSuperiorLongitudinalviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightArcuateviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightCorticospinalviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightSuperiorLongitudinalviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_core_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-ForcepsMinorviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_core_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftArcuateviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_core_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftCorticospinalviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_core_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-LeftSuperiorLongitudinalviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_core_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightArcuateviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_core_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightCorticospinalviz_dwi.html', '/home/runner/AFQ_data/stanford_hardi/derivatives/afq/sub-01/ses-01/viz_core_bundles/sub-01_ses-01_coordsys-RASMM_trkmethod-probCSD_recogmethod-AFQ_desc-RightSuperiorLongitudinalviz_dwi.html']

Total running time of the script: (16 minutes 40.101 seconds)

Estimated memory usage: 1656 MB

Gallery generated by Sphinx-Gallery