From 5c099f659129ecd09c45102f763f39fea97798e6 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Fri, 5 May 2023 09:16:44 -0400 Subject: [PATCH] Pare down giant comment blocks that largely do what Git already does --- src/nidm/experiment/Query.py | 32 +---------- src/nidm/experiment/tools/bidsmri2nidm.py | 32 ++--------- src/nidm/experiment/tools/csv2nidm.py | 37 +++--------- src/nidm/experiment/tools/nidm2bids.py | 43 +++----------- src/nidm/experiment/tools/nidm_concat.py | 32 +---------- src/nidm/experiment/tools/nidm_convert.py | 32 +---------- src/nidm/experiment/tools/nidm_linreg.py | 33 +---------- src/nidm/experiment/tools/nidm_merge.py | 32 +---------- src/nidm/experiment/tools/nidm_query.py | 32 +---------- src/nidm/experiment/tools/nidm_utils.py | 32 +---------- src/nidm/experiment/tools/nidm_visualize.py | 32 +---------- .../tools/repronim_simple2_brainvolumes.py | 57 +++++-------------- 12 files changed, 44 insertions(+), 382 deletions(-) diff --git a/src/nidm/experiment/Query.py b/src/nidm/experiment/Query.py index 4b09146..83e0609 100644 --- a/src/nidm/experiment/Query.py +++ b/src/nidm/experiment/Query.py @@ -1,33 +1,5 @@ -# ***************************************************************************** -# ***************************************************************************** -# nidm_query.py -# License: GPL -# ***************************************************************************** -# ***************************************************************************** -# Date: 8-1-18 Coded by: David Keator (dbkeator@gmail.com) -# Filename: nidm_query.py -# -# Program description: This program provides query functionality for NIDM-Experiment files -# -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: os, sys, rdflib, pandas, argparse, logging -# ***************************************************************************** -# Start date: 8-1-18 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +"""This program provides query functionality for NIDM-Experiment files""" + import functools import hashlib import json diff --git a/src/nidm/experiment/tools/bidsmri2nidm.py b/src/nidm/experiment/tools/bidsmri2nidm.py index ebad76a..cf1b96c 100755 --- a/src/nidm/experiment/tools/bidsmri2nidm.py +++ b/src/nidm/experiment/tools/bidsmri2nidm.py @@ -1,30 +1,8 @@ -# !/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# bidsmri2nidm.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 10-2-17 Coded by: David Keator (dbkeator@gmail.com) -# Filename: bidsmri2nidm.py -# -# Program description: This program will convert a BIDS MRI dataset to a NIDM-Experiment -# RDF document. It will parse phenotype information and simply store variables/values -# and link to the associated json data dictionary file. -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +""" +This program will convert a BIDS MRI dataset to a NIDM-Experiment RDF document. +It will parse phenotype information and simply store variables/values and link +to the associated json data dictionary file. +""" from argparse import ArgumentParser, RawTextHelpFormatter import csv diff --git a/src/nidm/experiment/tools/csv2nidm.py b/src/nidm/experiment/tools/csv2nidm.py index 76251a1..e237273 100644 --- a/src/nidm/experiment/tools/csv2nidm.py +++ b/src/nidm/experiment/tools/csv2nidm.py @@ -1,33 +1,10 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# csv2nidm.py -# License:Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 01-19-18 Coded by: David Keator (dbkeator@gmail.com) -# Filename: csv2nidm.py -# -# Program description: This program will load in a CSV file and iterate over the header -# variable names performing an elastic search of https://scicrunch.org/ for NIDM-ReproNim -# tagged terms that fuzzy match the variable names. The user will then interactively pick -# a term to associate with the variable name. The resulting annotated CSV data will -# then be written to a NIDM data file. -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +""" +This program will load in a CSV file and iterate over the header variable names +performing an elastic search of https://scicrunch.org/ for NIDM-ReproNim tagged +terms that fuzzy match the variable names. The user will then interactively +pick a term to associate with the variable name. The resulting annotated CSV +data will then be written to a NIDM data file. +""" from argparse import ArgumentParser from io import StringIO diff --git a/src/nidm/experiment/tools/nidm2bids.py b/src/nidm/experiment/tools/nidm2bids.py index 0e19fa0..a51fb27 100644 --- a/src/nidm/experiment/tools/nidm2bids.py +++ b/src/nidm/experiment/tools/nidm2bids.py @@ -1,38 +1,11 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# NIDM2BIDSMRI.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 10-2-17 Coded by: David Keator (dbkeator@gmail.com) -# Filename: NIDM2BIDSMRI.py -# -# Program description: This program will convert a NIDM-Experiment RDF document -# to a BIDS dataset. The program will query the NIDM-Experiment document for subjects, -# MRI scans, and associated assessments saving the MRI data to disk in an organization -# according to the BIDS specification, the demographics metadata to a participants.tsv -# file, the project-level metadata to a dataset_description.json file, and the -# assessments to *.tsv/*.json file pairs in a phenotypes directory. -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# Start date: 10-2-17 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +""" +This program will convert a NIDM-Experiment RDF document to a BIDS dataset. +The program will query the NIDM-Experiment document for subjects, MRI scans, +and associated assessments saving the MRI data to disk in an organization +according to the BIDS specification, the demographics metadata to a +participants.tsv file, the project-level metadata to a dataset_description.json +file, and the assessments to *.tsv/*.json file pairs in a phenotypes directory. +""" from argparse import ArgumentParser from io import StringIO diff --git a/src/nidm/experiment/tools/nidm_concat.py b/src/nidm/experiment/tools/nidm_concat.py index 010d7bf..23b971d 100644 --- a/src/nidm/experiment/tools/nidm_concat.py +++ b/src/nidm/experiment/tools/nidm_concat.py @@ -1,34 +1,4 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# nidm_utils.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 11-28-18 Coded by: David Keator (dbkeator@gmail.com) -# Filename: nidm_utils.py -# -# Program description: Tools for working with NIDM-Experiment files -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# Start date: 11-28-18 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +"""Tools for working with NIDM-Experiment files""" import click from nidm.experiment.Query import GetMergedGraph diff --git a/src/nidm/experiment/tools/nidm_convert.py b/src/nidm/experiment/tools/nidm_convert.py index 0c27fa7..ef6e584 100644 --- a/src/nidm/experiment/tools/nidm_convert.py +++ b/src/nidm/experiment/tools/nidm_convert.py @@ -1,34 +1,4 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# nidm_utils.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 11-28-18 Coded by: David Keator (dbkeator@gmail.com) -# Filename: nidm_utils.py -# -# Program description: Tools for working with NIDM-Experiment files -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# Start date: 11-28-18 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +""" Tools for working with NIDM-Experiment files """ from os.path import basename, join, splitext import click diff --git a/src/nidm/experiment/tools/nidm_linreg.py b/src/nidm/experiment/tools/nidm_linreg.py index 064b107..d1afbd8 100644 --- a/src/nidm/experiment/tools/nidm_linreg.py +++ b/src/nidm/experiment/tools/nidm_linreg.py @@ -1,35 +1,4 @@ -# coding=utf-8 -# !/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# nidm_linreg.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 07-26-22 Coded by: Ashmita Kumar (ashmita.kumar@gmail.com) -# Filename: nidm_linreg.py -# -# Program description: This program provides a tool to complete a linear regression on nidm files -# -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: os, sys, tempfile, pandas, click, nidm, csv, sklearn, numpy, statsmodel.api, patsy.contrasts -# ***************************************************************************** -# Start date: 6-15-20 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +"""This program provides a tool to complete a linear regression on nidm files""" import csv import os diff --git a/src/nidm/experiment/tools/nidm_merge.py b/src/nidm/experiment/tools/nidm_merge.py index 3b0bd7f..74fdf76 100644 --- a/src/nidm/experiment/tools/nidm_merge.py +++ b/src/nidm/experiment/tools/nidm_merge.py @@ -1,34 +1,4 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# nidm_utils.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 11-28-18 Coded by: David Keator (dbkeator@gmail.com) -# Filename: nidm_utils.py -# -# Program description: Tools for working with NIDM-Experiment files -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# Start date: 11-28-18 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +"""Tools for working with NIDM-Experiment files""" import click from rdflib import Graph, util diff --git a/src/nidm/experiment/tools/nidm_query.py b/src/nidm/experiment/tools/nidm_query.py index 00921e4..5c1ee8c 100644 --- a/src/nidm/experiment/tools/nidm_query.py +++ b/src/nidm/experiment/tools/nidm_query.py @@ -1,34 +1,4 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# nidm_query.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 8-1-18 Coded by: David Keator (dbkeator@gmail.com) -# Filename: nidm_query.py -# -# Program description: This program provides query functionality for NIDM-Experiment files -# -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: os, sys, rdflib, pandas, argparse, logging -# ***************************************************************************** -# Start date: 8-1-18 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +"""This program provides query functionality for NIDM-Experiment files""" from json import dumps import os diff --git a/src/nidm/experiment/tools/nidm_utils.py b/src/nidm/experiment/tools/nidm_utils.py index a48b67a..feb9a00 100644 --- a/src/nidm/experiment/tools/nidm_utils.py +++ b/src/nidm/experiment/tools/nidm_utils.py @@ -1,34 +1,4 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# nidm_utils.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 11-28-18 Coded by: David Keator (dbkeator@gmail.com) -# Filename: nidm_utils.py -# -# Program description: Tools for working with NIDM-Experiment files -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# Start date: 11-28-18 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +""" Tools for working with NIDM-Experiment files """ from argparse import ArgumentParser import os.path diff --git a/src/nidm/experiment/tools/nidm_visualize.py b/src/nidm/experiment/tools/nidm_visualize.py index 98f4a3f..b77a7ff 100644 --- a/src/nidm/experiment/tools/nidm_visualize.py +++ b/src/nidm/experiment/tools/nidm_visualize.py @@ -1,34 +1,4 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# nidm_utils.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 11-28-18 Coded by: David Keator (dbkeator@gmail.com) -# Filename: nidm_utils.py -# -# Program description: Tools for working with NIDM-Experiment files -# -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# Start date: 11-28-18 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +""" Tools for working with NIDM-Experiment files """ import os.path import click diff --git a/src/nidm/experiment/tools/repronim_simple2_brainvolumes.py b/src/nidm/experiment/tools/repronim_simple2_brainvolumes.py index aab74a1..0b3a3b0 100644 --- a/src/nidm/experiment/tools/repronim_simple2_brainvolumes.py +++ b/src/nidm/experiment/tools/repronim_simple2_brainvolumes.py @@ -1,45 +1,18 @@ -#!/usr/bin/env python -# ***************************************************************************** -# ***************************************************************************** -# repronim_simple2_brainvolumes.py -# License: Apache License, Version 2.0 -# ***************************************************************************** -# ***************************************************************************** -# Date: 03-22-19 Coded by: David Keator (dbkeator@gmail.com) -# Filename: repronim_simple2_brainvolumes.py -# -# Program description: This program will load in a CSV file made during simple-2 -# brain volumes experiment which has the following organization: -# -# source FSL FSL FSL -# participant_id left nucleus accumbens volume left amygdala volume left caudate nucleus volume -# sub-0050002 796.4723293 1255.574283 4449.579039 -# sub-0050003 268.9688215 878.7860634 3838.602449 -# sub-0050004 539.0969914 1195.288168 3561.518188 -# -# If will use the first row to determine the software used for the segmentations and the -# second row for the variable names. Then it does a simple NIDM conversion using -# example model in: https://docs.google.com/document/d/1PyBoM7J0TuzTC1TIIFPDqd05nomcCM5Pvst8yCoqLng/edit - -# ***************************************************************************** -# Development environment: Python - PyCharm IDE -# -# ***************************************************************************** -# System requirements: Python 3.X -# Libraries: pybids, numpy, matplotlib, pandas, scipy, math, dateutil, datetime,argparse, -# os,sys,getopt,csv -# ***************************************************************************** -# Start date: 03-22-18 -# Update history: -# DATE MODIFICATION Who -# -# -# ***************************************************************************** -# Programmer comments: -# -# -# ***************************************************************************** -# ***************************************************************************** +""" +Program description: This program will load in a CSV file made during simple-2 +brain volumes experiment which has the following organization:: + + source FSL FSL FSL + participant_id left nucleus accumbens volume left amygdala volume left caudate nucleus volume + sub-0050002 796.4723293 1255.574283 4449.579039 + sub-0050003 268.9688215 878.7860634 3838.602449 + sub-0050004 539.0969914 1195.288168 3561.518188 + +If will use the first row to determine the software used for the segmentations +and the second row for the variable names. Then it does a simple NIDM +conversion using example model in: +https://docs.google.com/document/d/1PyBoM7J0TuzTC1TIIFPDqd05nomcCM5Pvst8yCoqLng/edit +""" from argparse import ArgumentParser from io import StringIO