Skip to content

Commit

Permalink
Merge pull request #80 from smoia/doc/docstrings
Browse files Browse the repository at this point in the history
Adding docstrings to scripts
  • Loading branch information
Stefano Moia authored Jan 27, 2020
2 parents d62fe52 + f27a777 commit e0ce249
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 115 deletions.
9 changes: 7 additions & 2 deletions phys2bids/cli/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
"""
Parser for phys2bids
"""

import argparse

Expand All @@ -13,10 +16,12 @@ def _get_parser():
-------
parser.parse_args() : argparse dict
"""
parser = argparse.ArgumentParser()
Notes
-----
# Argument parser follow template provided by RalphyZ.
# https://stackoverflow.com/a/43456577
"""
parser = argparse.ArgumentParser()
optional = parser._action_groups.pop()
required = parser.add_argument_group('Required Argument:')
required.add_argument('-in', '--input-file',
Expand Down
17 changes: 16 additions & 1 deletion phys2bids/interfaces/acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@

def populate_phys_input(filename, chtrig):
"""
Populate object phys_input
Populate object phys_input from acq files.
Parameters
----------
filename: str
path to the txt labchart file
chtrig : int
index of trigger channel
Returns
-------
BlueprintInput
See Also
--------
physio_obj.BlueprintInput
"""

data = read_file(filename).channels
Expand Down
16 changes: 10 additions & 6 deletions phys2bids/interfaces/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@
import numpy as np
from phys2bids.physio_obj import BlueprintInput


def populate_phys_input(filename, chtrig):
"""
Populate object phys_input
for now this works only with labchart files
Input (Properties)
------------------
Parameters
----------
filename: str
path to the txt labchart file
chtrig : int
index of trigger channel
Output
------------------
BlueprintInput object for more see BlueprintInput docs
Returns
-------
BlueprintInput
See Also
--------
physio_obj.BlueprintInput
"""
header = []
channel_list = []
Expand Down
30 changes: 18 additions & 12 deletions phys2bids/phys2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def print_summary(filename, ntp_expected, ntp_found, samp_freq, time_offset, out
"""
Prints a summary onscreen and in file with informations on the files.
Input
-----
Parameters
----------
filename: str
Name of the input of phys2bids.
ntp_expected: int
Expand All @@ -58,8 +58,9 @@ def print_summary(filename, ntp_expected, ntp_found, samp_freq, time_offset, out
outfile: str or path
Fullpath to output file.
Outcome
-------
Notes
-----
Outcome:
summary: str
Prints the summary on screen
outfile: .log file
Expand All @@ -83,8 +84,8 @@ def print_json(outfile, samp_freq, time_offset, ch_name):
"""
Prints the json required by BIDS format.
Input
-----
Parameters
----------
outfile: str or path
Fullpath to output file.
samp_freq: float
Expand All @@ -94,9 +95,9 @@ def print_json(outfile, samp_freq, time_offset, ch_name):
ch_name: list of str
List of channel names, as specified by BIDS format.
Outcome
-------
Notes
-----
Outcome:
outfile: .json file
File containing information for BIDS.
"""
Expand All @@ -113,8 +114,8 @@ def use_heuristic(heur_file, sub, ses, filename, outdir, record_label=''):
Import the heuristic file specified by the user and uses its output
to rename the file.
Input
-----
Parameters
----------
heur_file: path
Fullpath to heuristic file.
sub: str or int
Expand All @@ -129,7 +130,7 @@ def use_heuristic(heur_file, sub, ses, filename, outdir, record_label=''):
record_label: str
Optional label for the "record" entry of BIDS.
Output
Returns
-------
heurpath: str or path
Returned fullpath to tsv.gz new file (post BIDS formatting).
Expand Down Expand Up @@ -180,6 +181,11 @@ def _main(argv=None):
Otherwise, it operates on the input to return a .tsv.gz file, possibily
in BIDS format.
Raises
------
NotImplementedError
If the file extension is not supported yet.
"""
options = _get_parser().parse_args(argv)
# Check options to make them internally coherent
Expand Down
Loading

0 comments on commit e0ce249

Please sign in to comment.