Skip to content

Commit

Permalink
Merge pull request #401 from seanhatton/fmriprep
Browse files Browse the repository at this point in the history
Added thickness and surface area switches
  • Loading branch information
dbkeator authored Jun 4, 2024
2 parents 669f75a + 78edd22 commit 6423c93
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 7 deletions.
69 changes: 62 additions & 7 deletions src/nidm/experiment/Query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,14 +1133,7 @@ def GetBrainVolumes(nidm_file_list):
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix fsl: <http://purl.org/nidash/fsl#>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix onli: <http://neurolog.unice.fr/ontoneurolog/v3.0/instrument.owl#>
prefix freesurfer: <https://surfer.nmr.mgh.harvard.edu/>
prefix dx: <http://ncitt.ncit.nih.gov/Diagnosis>
prefix ants: <http://stnava.github.io/ANTs/>
prefix dct: <http://purl.org/dc/terms/>
prefix dctypes: <http://purl.org/dc/dcmitype/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select distinct ?ID ?tool ?softwareLabel ?federatedLabel ?laterality ?volume
Expand All @@ -1163,10 +1156,72 @@ def GetBrainVolumes(nidm_file_list):
}
"""
df = sparql_query_nidm(nidm_file_list.split(","), query, output_file=None)
return df

def GetBrainThickness(nidm_file_list):
query = """
# This query simply returns the brain thickness data without dependencies on other demographics/assessment measures.
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select distinct ?ID ?tool ?softwareLabel ?federatedLabel ?laterality ?volume
where {
?tool_act a prov:Activity ;
prov:qualifiedAssociation [prov:agent [nidm:NIDM_0000164 ?tool]] .
?tool_act prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .
?tool_entity prov:wasGeneratedBy ?tool_act ;
?measure ?volume .
?tool_entity prov:wasGeneratedBy ?tool_act ;
?measure ?volume .
?measure a/rdfs:subClassOf* nidm:DataElement ;
rdfs:label ?softwareLabel;
nidm:measureOf <http://uri.interlex.org/base/ilx_0111689> .
OPTIONAL {?measure nidm:isAbout ?federatedLabel }.
OPTIONAL {?measure nidm:hasLaterality ?laterality }.
}
"""
df = sparql_query_nidm(nidm_file_list.split(","), query, output_file=None)
return df

def GetBrainSurfaceArea(nidm_file_list):
query = """
# This query simply returns the brain surface area data without dependencies on other demographics/assessment measures.
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select distinct ?ID ?tool ?softwareLabel ?federatedLabel ?laterality ?volume
where {
?tool_act a prov:Activity ;
prov:qualifiedAssociation [prov:agent [nidm:NIDM_0000164 ?tool]] .
?tool_act prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .
?tool_entity prov:wasGeneratedBy ?tool_act ;
?measure ?volume .
?tool_entity prov:wasGeneratedBy ?tool_act ;
?measure ?volume .
?measure a/rdfs:subClassOf* nidm:DataElement ;
rdfs:label ?softwareLabel;
nidm:measureOf <http://purl.obolibrary.org/obo/PATO_0001323> .
OPTIONAL {?measure nidm:isAbout ?federatedLabel }.
OPTIONAL {?measure nidm:hasLaterality ?laterality }.
}
"""
df = sparql_query_nidm(nidm_file_list.split(","), query, output_file=None)
return df

def expandNIDMAbbreviation(shortKey) -> str:
"""
Expand Down
30 changes: 30 additions & 0 deletions src/nidm/experiment/tools/nidm_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from nidm.experiment.Query import (
GetBrainVolumeDataElements,
GetBrainVolumes,
GetBrainThickness,
GetBrainSurfaceArea,
GetDataElements,
GetInstrumentVariables,
GetParticipantIDs,
Expand Down Expand Up @@ -81,6 +83,18 @@
is_flag=True,
help="Parameter, if set, will return all brain volume data elements and values along with participant IDs in NIDM file",
)
@optgroup.option(
"--get_brainthickness",
"-bt",
is_flag=True,
help="Parameter, if set, will return all brain thickness data elements and values along with participant IDs in NIDM file",
)
@optgroup.option(
"--get_brainsurfacearea",
"-bsa",
is_flag=True,
help="Parameter, if set, will return all brain surface area data elements and values along with participant IDs in NIDM file",
)
@optgroup.option(
"--get_fields",
"-gf",
Expand Down Expand Up @@ -122,6 +136,8 @@ def query(
get_instrument_vars,
get_dataelements,
get_brainvols,
get_brainthickness,
get_brainsurfacearea,
get_dataelements_brainvols,
get_fields,
uri,
Expand Down Expand Up @@ -266,6 +282,20 @@ def query(
brainvol.to_csv(output_file)
else:
print(brainvol.to_string())
elif get_brainthickness:
brainthx = GetBrainThickness(nidm_file_list=nidm_file_list)
# if output file parameter specified
if output_file is not None:
brainthx.to_csv(output_file)
else:
print(brainvol.to_string())
elif get_brainsurfacearea:
brainsurfacearea = GetBrainSurfaceArea(nidm_file_list=nidm_file_list)
# if output file parameter specified
if output_file is not None:
brainsurfacearea.to_csv(output_file)
else:
print(brainvol.to_string())
elif query_file:
df = sparql_query_nidm(nidm_file_list.split(","), query_file, output_file)

Expand Down

0 comments on commit 6423c93

Please sign in to comment.