Skip to content

Commit

Permalink
✨ manually add scout to json and hint to use it
Browse files Browse the repository at this point in the history
Also update Makeifle and add markdown to requirements.
Sequence description is now tracking the previously discarded rules sub key.

The hard coded scout entry illustrates where data is stored and pulled from.
  • Loading branch information
WillForan committed Apr 29, 2024
1 parent a6398f8 commit 285ae38
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
8 changes: 6 additions & 2 deletions entity_ux/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
bids-table_ver-1.10.0dev.json: make_json.py requirements.txt
./make_json.py

serve:
python3 -m http.server

bids-specification/:
git clone https://github.com/bids-standard/bids-specification

bids-table_ver-1.10.0dev.json:
./make_json.py
2 changes: 1 addition & 1 deletion entity_ux/bids-table_ver-1.10.0dev.json

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions entity_ux/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,18 @@
</div>
<div id="reproin">
<h2>Create a <a href="https://dbic-handbook.readthedocs.io/en/latest/mri/reproin.html">ReproIn </a>spec conforming sequence name</h2>
Pick a DataType and Suffix label to dynamically generate a name within the cockpit image below (text is selectable and copyable). <br>See <a href="#suffix-options"> enumerated descriptions </a> below for more info. <br> <span style=font-size:smaller> Suffix and entities details are described in <a href="https://bids-specification.readthedocs.io/en/stable/glossary.html">BIDS glossary</a>. Entity requirements are also tabulated in adjacent <a href="https://bids-specification.readthedocs.io/en/stable/appendices/entity-table.html"> BIDS entity table</a> documentation.</span>
Pick a DataType and Suffix label to dynamically generate a name within the cockpit image below (text is selectable and copyable). <br>
See <a href="#suffix-options"> enumerated descriptions </a> below for more info. <br>
<!-- TODO: scout index hard coded at 37. will need to change -->
<span style=font-size:smaller> Suffix and entities details are described in <a href="https://bids-specification.readthedocs.io/en/stable/glossary.html">BIDS glossary</a>.
Entity requirements are also tabulated in adjacent <a href="https://bids-specification.readthedocs.io/en/stable/appendices/entity-table.html"> BIDS entity table</a> documentation.

</span>
<br>
<b style="font-size:smaller">Hint: hover your mouse over label options or entity text boxes to see the tooltip description</b></br>
<b style="font-size:smaller">Hints:<br>
hover your mouse over label options or entity text boxes to see the tooltip description<br>
Consider using <i>scout</i><a onclick="choose('anat', '37')" href="#">(choose)</a> to label the session (<a href="https://github.com/nipy/heudiconv/blob/master/heudiconv/heuristics/reproin.py#L629">ref source code</a>).
</b></br>
<div id="all-reproin-inputs">
<div id=cont-datatype class=column>
<label for=datatype> 1. Select DataType ("seqtype")</label></br>
Expand All @@ -220,7 +229,8 @@ <h2>Create a <a href="https://dbic-handbook.readthedocs.io/en/latest/mri/reproin
<br>

<h2>ReproIn specification</h2>
Defined on <a href="https://dbic-handbook.readthedocs.io/en/latest/mri/reproin.html">dbic-handbook</a>. Parsed from DICOM to <a href="https://bids.neuroimaging.io/">BIDS</a> conforming nifti+json file hierarchy by <a href="https://heudiconv.readthedocs.io/en/latest/">heudiconv</a> in <a href="https://github.com/nipy/heudiconv/blob/master/heudiconv/heuristics/reproin.py">reproin.py</a> or via <a href="https://docs.flywheel.io/User_Guides/user_bids_study-design_spreadsheet/">Flywheel's</a> <a href="https://gitlab.com/flywheel-io/public/bids-client/-/blob/master/flywheel_bids/templates/reproin.json">curation template<a>, ready to be input for <a href="https://bids-apps.neuroimaging.io/apps/">BIDS Apps</a>.
Defined on <a href="https://dbic-handbook.readthedocs.io/en/latest/mri/reproin.html">dbic-handbook</a>.
Parsed from DICOM to <a href="https://bids.neuroimaging.io/">BIDS</a> conforming nifti+json file hierarchy by <a href="https://heudiconv.readthedocs.io/en/latest/">heudiconv</a> in <a href="https://github.com/nipy/heudiconv/blob/master/heudiconv/heuristics/reproin.py">reproin.py</a> or via <a href="https://docs.flywheel.io/User_Guides/user_bids_study-design_spreadsheet/">Flywheel's</a> <a href="https://gitlab.com/flywheel-io/public/bids-client/-/blob/master/flywheel_bids/templates/reproin.json">curation template<a>, ready to be input for <a href="https://bids-apps.neuroimaging.io/apps/">BIDS Apps</a>.
<pre><code>
&lt;seqtype[-label]&gt;[_ses-&lt;SESID&gt;]
[_task-&lt;TASKID&gt;][_acq-&lt;ACQLABEL&gt;][_run-&lt;RUNID&gt;][_dir-&lt;DIR&gt;][&lt;more BIDS&gt;]
Expand Down
21 changes: 19 additions & 2 deletions entity_ux/make_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,37 @@ def write_json(fname, data):
bids_dict['objects'][obj][k]['description'] = markdown(bids_dict['objects'][obj][k]['description'])

table = dict()
# add reproin specific 'scout'
bids_dict['objects']['suffixes']['scout'] = \
{"value": "scout",
"display_name": "Scout localizer",
"description": "ReproIn specific entity label for easily labeling a session. Using heudiconv, labeling this sequence session only is sufficent. You do not need to put <code>ses</code> on every sequence name! See <a href=https://github.com/nipy/heudiconv/blob/master/heudiconv/heuristics/reproin.py#L629>source reference</a>",

Check failure on line 41 in entity_ux/make_json.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

sufficent ==> sufficient
"unit": "arbitrary"}
bids_dict['rules']['files']['raw']['anat']['scout'] = \
{"suffixes": ["scout"], "extensions": ['.dcm'],
"datatypes": ['anat'],
"entities": {"session": "optional", "acquisition": "optional"}}

for keydesc, rules in bids_dict['rules']['files']['raw'].items():
for rule in rules.values():
# subkey is like nonparametric (anat), fmap (func)
# only used to add to description
for subkey, rule in rules.items():

# only care about nifti files (MR data)
if '.nii' not in rule['extensions']:
if '.nii' not in rule.get('extensions') and subkey != 'scout':
continue

# get full entity information. repeats a lot of info but easy to query
entities = {k: {**bids_dict['objects']['entities'][k], 'required': v}
for k,v in rule['entities'].items()}

# repeat entities and pull full object (desc, unit, display_name) for each suffix
suffix_full = [{'entities': entities,
**bids_dict['objects']['suffixes'][i]} for i in rule['suffixes']]

for suffix in suffix_full:
suffix['description'] += f'\n<br><code>{subkey}</code>'

# NB. currently all datatypes of interest are only in one datatype?
# shouldn't epi be repeated for fmap and func? sbref for func and dwi?
for datatype in rule['datatypes']:
Expand Down
2 changes: 1 addition & 1 deletion entity_ux/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bidsschematools >= 0.8.0

markdown >= 3.6

0 comments on commit 285ae38

Please sign in to comment.