|
4 | 4 | # SPDX-License-Identifier: BSD-3-Clause |
5 | 5 |
|
6 | 6 | import json |
7 | | -import os.path as op |
8 | 7 | import textwrap |
9 | 8 | from pathlib import Path |
10 | 9 |
|
@@ -151,8 +150,8 @@ def _summarize_dataset(root): |
151 | 150 | template_dict : dict |
152 | 151 | A dictionary of values for various template strings. |
153 | 152 | """ |
154 | | - dataset_descrip_fpath = op.join(root, "dataset_description.json") |
155 | | - if not op.exists(dataset_descrip_fpath): |
| 153 | + dataset_descrip_fpath = root / "dataset_description.json" |
| 154 | + if not dataset_descrip_fpath.exists(): |
156 | 155 | return dict() |
157 | 156 |
|
158 | 157 | # read file and 'REQUIRED' components of it |
@@ -186,8 +185,8 @@ def _summarize_participants_tsv(root): |
186 | 185 | template_dict : dict |
187 | 186 | A dictionary of values for various template strings. |
188 | 187 | """ |
189 | | - participants_tsv_fpath = op.join(root, "participants.tsv") |
190 | | - if not op.exists(participants_tsv_fpath): |
| 188 | + participants_tsv_fpath = root / "participants.tsv" |
| 189 | + if not participants_tsv_fpath.exists(): |
191 | 190 | return dict() |
192 | 191 |
|
193 | 192 | participants_tsv = _from_tsv(str(participants_tsv_fpath)) |
@@ -312,7 +311,7 @@ def _summarize_sidecar_json(root, scans_fpaths): |
312 | 311 | for scan in scans: |
313 | 312 | # summarize metadata of recordings |
314 | 313 | bids_path, ext = _parse_ext(scan) |
315 | | - datatype = op.dirname(scan) |
| 314 | + datatype = scan.parent |
316 | 315 | if datatype not in ALLOWED_DATATYPES: |
317 | 316 | continue |
318 | 317 |
|
@@ -400,7 +399,7 @@ def _summarize_channels_tsv(root, scans_fpaths): |
400 | 399 | for scan in scans: |
401 | 400 | # summarize metadata of recordings |
402 | 401 | bids_path, _ = _parse_ext(scan) |
403 | | - datatype = op.dirname(scan) |
| 402 | + datatype = scan.parent |
404 | 403 | if datatype not in ["meg", "eeg", "ieeg"]: |
405 | 404 | continue |
406 | 405 |
|
@@ -465,6 +464,8 @@ def make_report(root, session=None, verbose=None): |
465 | 464 | The paragraph wrapped with 80 characters per line |
466 | 465 | describing the summary of the subjects. |
467 | 466 | """ |
| 467 | + root = Path(root) |
| 468 | + |
468 | 469 | # high level summary |
469 | 470 | subjects = get_entity_vals(root, entity_key="subject") |
470 | 471 | sessions = get_entity_vals(root, entity_key="session") |
|
0 commit comments