From 6e35745b40ce3ad49b64f2fbefb4b63eed1ee1ac Mon Sep 17 00:00:00 2001 From: valosekj Date: Sat, 3 Apr 2021 11:33:26 +0200 Subject: [PATCH 01/10] improve appearance of pervendor figures --- scripts/generate_figures.py | 114 +++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 42 deletions(-) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index 0d435eb..f145e68 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -46,7 +46,7 @@ # color to assign to each MRI model for the figure vendor_to_color = { - 'GE': 'black', + 'GE': 'orange', 'Philips': 'dodgerblue', 'Siemens': 'limegreen', } @@ -113,6 +113,7 @@ } # titles for individual subplots +# TODO - add also another ROIs/labels to the dict below roi_to_label = { 'spinal cord': 'Spinal cord', 'white matter': 'White matter', @@ -485,68 +486,97 @@ def generate_level_evolution_pervendor(df_vendor, df_summary_vendor, metric, pat # optimize font size FONTSIZE = 20 TICKSIZE = 15 - LEGENDSIZE = 11 + LEGENDSIZE = 12 + # transparency of artists + ALPHA = 0.6 - fig, _ = plt.subplots(figsize=(14, 7)) - # add master title for whole figure - fig.suptitle('{} for totally {} subjects across {} vendors.'.format(metric_to_title[metric], - df_summary_vendor['M'].sum() + - df_summary_vendor['F'].sum(), - len(vendor_to_color)), fontsize=FONTSIZE) + # Initialize figure for subplots + # TODO - modify command below to allow working with different number of ROIs/labels + fig, axs = plt.subplots(2, 3, figsize=(14, 8), sharex=True, sharey=True) + # Flatten 2D array into 1D to allow iteration by loop + axs = axs.ravel() - # loop across vendors + # add master title for whole figure + fig.suptitle('{} for {} subjects across {} vendors'. + format(metric_to_title[metric], + df_summary_vendor['M'].sum() + + df_summary_vendor['F'].sum(), + len(vendor_to_color)), + fontsize=FONTSIZE, fontweight='bold') + + # loop across vendors (Siemens, Philips, ...) for vendor, row in df_vendor.iterrows(): - # loop across roi/labels + # loop across roi/labels (spinal cord, white matter, ...) for index, label in enumerate(roi_to_label.keys()): - # create individual subplots - # TODO - modify command below to be able to work with different number of ROIs - ax = plt.subplot(2, 3, index + 1) - # loop across levels + y = list() # mean values e = list() # sd values + # loop across levels (C2, C3, ...) for level in levels_to_label.keys(): - # get mean value for given label (e.g, C2, C3, etc) and given label/roi (e.g., spinal cord etc.) + # get mean value for given label (e.g, C2, ...) and given label/roi (e.g., spinal cord, ...) y.append(row[level,label][0]) - # get sd value for given label (e.g, C2, C3, etc) and given label/roi (e.g., spinal cord etc.) + # get sd value for given label (e.g, C2, ...) and given label/roi (e.g., spinal cord, ...) e.append(row[level, label][1]) # plot mean and sd values pervendor for each level (C2, C3, C4, C5) x = [float(key) for key in levels_to_label] # individual levels - 2,3,4,5 - plt.errorbar(x, - y, - e, - marker=vendor_to_marker[vendor], # change marker symbol based on vendor - markersize=10, # size of marker symbol - capsize=5, # the length of the error bar caps - alpha=0.5, # transparency - label=vendor) + axs[index].errorbar(x, # vertebral levels + y, # mean values for currently processed qMRI metric (e.g., FA, ...) + e, # sd values for currently processed qMRI metric (e.g., FA, ...) + marker=vendor_to_marker[vendor], # change marker symbol based on vendor + markersize=10, # size of marker symbol + capsize=5, # the length of the error bar caps + alpha=ALPHA, # transparency + color=vendor_to_color[vendor], + label=vendor) # label for legend # rename xticks to C2, C3, C4, C5 - plt.xticks(x, levels_to_label.values(), fontsize=TICKSIZE) - # Increase site if yticks - plt.yticks(fontsize=TICKSIZE) + #axs[index].xticks(x, levels_to_label.values(), fontsize=TICKSIZE) + # Rename x-tick labels to C2, C3, C4, C5 + plt.setp(axs[index], xticks=x, xticklabels=levels_to_label.values()) + # Increase size of x- and y-ticks + plt.setp(axs[index].xaxis.get_majorticklabels(), fontsize=TICKSIZE) + plt.setp(axs[index].yaxis.get_majorticklabels(), fontsize=TICKSIZE) # add grid - plt.grid(axis='y', linestyle="--") - ax.set_ylabel(metric_to_label[metric], fontsize=TICKSIZE) + axs[index].grid(axis='y', linestyle="--") # add title to individual subpolots (i.e., ROI/label) - plt.title(roi_to_label[label], fontsize=FONTSIZE) - - # show legend only one time (in right up corner) - if index == 2: - # place legend next to last subplot - leg = plt.legend(bbox_to_anchor=(1.1, 1.03), fontsize=LEGENDSIZE) - # insert number of subjects and number of sites per vendor into legend - # loop across vendors - for num in range(0,len(leg.get_texts())): - leg.get_texts()[num].set_text('{}: {} subjects, {} sites'.format(df_summary_vendor.index.values[num], - df_summary_vendor.iloc[num, 0], - df_summary_vendor.iloc[num, 1])) + axs[index].set_title(roi_to_label[label], fontsize=FONTSIZE) + # set y-label (FA, MD, ...) only once for each row + # TODO - number of indexes will have to be fixed when number of ROIs/labels will be changed + if index == 0 or index == 3: + axs[index].set_ylabel(metric_to_label[metric], fontsize=TICKSIZE) + + + # LEGEND - create custom legend + # https://stackoverflow.com/questions/9834452/how-do-i-make-a-single-legend-for-many-subplots-with-matplotlib + # https://stackoverflow.com/questions/4700614/how-to-put-the-legend-out-of-the-plot + lines = list() # initialize list for individual symbols in the legend + labels = list() # initialize list for individual text labels in the legend + # loop across vendors (Siemens, Philips, ...) + for num, vendor in enumerate(vendor_to_color): + lines.append(Line2D([0], [0], color=vendor_to_color[vendor], + marker=vendor_to_marker[vendor], + markersize=LEGENDSIZE, + alpha=ALPHA, + linestyle='')) + labels.append('{}: {} subjects, {} sites'.format(df_summary_vendor.index.values[num], + df_summary_vendor.iloc[num, 0], + df_summary_vendor.iloc[num, 1])) # Move subplots closer to each other plt.subplots_adjust(wspace=-0.5) plt.tight_layout() + + # Insert legend below subplots, NB - this line has to be below the plt.tight_layout() + legend = fig.legend(lines, labels, loc='lower left', bbox_to_anchor=(0.2, 0), + bbox_transform=plt.gcf().transFigure, ncol=len(lines), fontsize=LEGENDSIZE) + # Change box's frame color to black (to be same as box around linear fit equation) + frame = legend.get_frame() + frame.set_edgecolor('black') + # tight layout of whole figure and shift master title up fig.tight_layout() - fig.subplots_adjust(top=0.88) + fig.subplots_adjust(top=0.88, bottom=0.1) + # save figure fname_fig = os.path.join(path_output, metric + '_per_vendor.png') plt.savefig(fname_fig, dpi=200) From a8421500e6b46b139241a1be91273985b4ca3bce Mon Sep 17 00:00:00 2001 From: valosekj Date: Sat, 3 Apr 2021 11:33:55 +0200 Subject: [PATCH 02/10] fix units for MD, AD, RD --- scripts/generate_figures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index f145e68..65ef291 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -105,9 +105,9 @@ # ylabel for subplots metric_to_label = { 'dti_fa': 'FA', - 'dti_md': 'MD [$mm^2.s^{-1}$]', - 'dti_ad': 'AD [$mm^2.s^{-1}$]', - 'dti_rd': 'RD [$mm^2.s^{-1}$]', + 'dti_md': 'MD [$× 10^{-3} mm^{2}/s$]', + 'dti_ad': 'AD [$× 10^{-3} mm^{2}/s$]', + 'dti_rd': 'RD [$× 10^{-3} mm^{2}/s$]', 'mtr': 'MTR [%]', 'mtsat': 'MTsat [%]', } From 81402452af24947e07df4ae37572ae2f9c3f76b3 Mon Sep 17 00:00:00 2001 From: valosekj Date: Sat, 3 Apr 2021 11:34:32 +0200 Subject: [PATCH 03/10] add metric abbreviation into pervendor figure --- scripts/generate_figures.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index 65ef291..06e3748 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -94,12 +94,12 @@ # master titles for figures with subplots metric_to_title = { - 'dti_fa': 'Fractional anisotropy', - 'dti_md': 'Mean diffusivity', - 'dti_ad': 'Axial diffusivity', - 'dti_rd': 'Radial diffusivity', - 'mtr': 'Magnetization transfer ratio', - 'mtsat': 'Magnetization transfer saturation', + 'dti_fa': 'Fractional anisotropy (FA)', + 'dti_md': 'Mean diffusivity (MD)', + 'dti_ad': 'Axial diffusivity (AD)', + 'dti_rd': 'Radial diffusivity (MD)', + 'mtr': 'Magnetization transfer ratio (MTR)', + 'mtsat': 'Magnetization transfer saturation (MTsat)', } # ylabel for subplots From 50828fd8bb379734315ba0f67ee11a02f2c39e35 Mon Sep 17 00:00:00 2001 From: valosekj Date: Sat, 3 Apr 2021 11:34:45 +0200 Subject: [PATCH 04/10] rearrange imports --- scripts/generate_figures.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index 06e3748..eec51f2 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -30,11 +30,14 @@ import yaml import numpy as np -from collections import defaultdict -from scipy.stats import f_oneway import matplotlib.pyplot as plt import logging +from collections import defaultdict +from scipy.stats import f_oneway +from matplotlib.lines import Line2D + + # Initialize logging logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) # default: logging.DEBUG, logging.INFO From 4e004a857cb16de0f6be2b88b032cb7a6e787840 Mon Sep 17 00:00:00 2001 From: valosekj Date: Sat, 3 Apr 2021 14:23:16 +0200 Subject: [PATCH 05/10] fix typo in RD title --- scripts/generate_figures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index eec51f2..a38389a 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -100,7 +100,7 @@ 'dti_fa': 'Fractional anisotropy (FA)', 'dti_md': 'Mean diffusivity (MD)', 'dti_ad': 'Axial diffusivity (AD)', - 'dti_rd': 'Radial diffusivity (MD)', + 'dti_rd': 'Radial diffusivity (RD)', 'mtr': 'Magnetization transfer ratio (MTR)', 'mtsat': 'Magnetization transfer saturation (MTsat)', } From 18ae4eb9921dd355cdf85550b35db3fb4b9c87d4 Mon Sep 17 00:00:00 2001 From: valosekj Date: Sun, 4 Apr 2021 14:08:25 +0200 Subject: [PATCH 06/10] comment fix --- scripts/generate_figures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index a38389a..9227eea 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -572,7 +572,7 @@ def generate_level_evolution_pervendor(df_vendor, df_summary_vendor, metric, pat # Insert legend below subplots, NB - this line has to be below the plt.tight_layout() legend = fig.legend(lines, labels, loc='lower left', bbox_to_anchor=(0.2, 0), bbox_transform=plt.gcf().transFigure, ncol=len(lines), fontsize=LEGENDSIZE) - # Change box's frame color to black (to be same as box around linear fit equation) + # Change box's frame color to black frame = legend.get_frame() frame.set_edgecolor('black') From a5df30d24821917966263d76d5c2833041ae5bad Mon Sep 17 00:00:00 2001 From: valosekj Date: Mon, 5 Apr 2021 09:03:40 +0200 Subject: [PATCH 07/10] script's description update --- scripts/extract_normative_metrics.py | 51 +++++++++++++++++++--------- scripts/generate_figures.py | 12 ++++--- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/scripts/extract_normative_metrics.py b/scripts/extract_normative_metrics.py index f49305d..f164c55 100644 --- a/scripts/extract_normative_metrics.py +++ b/scripts/extract_normative_metrics.py @@ -1,28 +1,47 @@ #!/usr/bin/env python -# ------------------------------------------------------- -# Extract qMRI metrics (FA, MD, AD, RD, MTR, MTsat) from -# individual ROIs/labels perlevel between C2 and C5 -# ROIs/labels to process can be specified by input yml file # -# Extracted metrics will be saved as *perlevel.csv files -# in results/perlevel directory +# Extract qMRI metrics (FA, MD, AD, RD, MTR, MTsat) for different ROIs/labels (SC, WM, GM, ...) along individual +# cervical levels (C2, C3, C4, C5) +# +# ROIs/labels to process can be specified by input yml file ('-yml-file' - option) +# +# Extracted metrics will be saved as *perlevel.csv files in "results/perlevel" directory # # USAGE: -# - parallel mode across multiple subjects (using SCT sct_run_batch function and extract_normative_metrics_wrapper.sh wrapper): -# sct_run_batch -jobs -1 -path-data ~/data-multi-subject/ -path-output ~/data-multi-subject_results -continue-on-error 1 -script scripts/extract_normative_metrics_wrapper.sh -# - same as above, but with yml file containing labels to process(passed by -script-args option): -# sct_run_batch -jobs -1 -path-data ~/data-multi-subject/ -path-output ~/data-multi-subject_results -continue-on-error 1 -script-args "-yml-file scripts/labels_to_process.yml" -script scripts/extract_normative_metrics_wrapper.sh +# - parallel mode across multiple subjects (using SCT sct_run_batch function and extract_normative_metrics_wrapper.sh +# wrapper): +# sct_run_batch +# -jobs -1 +# -path-data ~/data-multi-subject/ +# -path-output ~/data-multi-subject_results +# -continue-on-error 1 +# -script scripts/extract_normative_metrics_wrapper.sh +# +# - same as above, but with yml file containing ROIs/labels to process(passed by '-script-args' option): +# sct_run_batch +# -jobs -1 +# -path-data ~/data-multi-subject/ +# -path-output ~/data-multi-subject_results +# -continue-on-error 1 +# -script-args "-yml-file scripts/labels_to_process.yml" +# -script scripts/extract_normative_metrics_wrapper.sh # -# (you can run the script only on some subjects, using -include flag, see sct_run_batch -h) +# (you can run the sct_run_batch script only on some subjects, using '-include flag', see sct_run_batch -h) # -# - single subject mode with default labels/ROIs: -# extract_normative_metrics.py -path-data ~/data-multi-subject_results -sub sub-amu01 -# - single subject mode with labels/ROIs defined by yml file: -# extract_normative_metrics.py -path-data ~/data-multi-subject_results -sub sub-amu01 -yml-file labels_to_process.yml +# - single subject mode (i.e., without parallelization using sct_run_batch) with default ROIs/labels: +# extract_normative_metrics.py +# -path-data ~/data-multi-subject_results +# -sub sub-amu01 +# +# - single subject mode (i.e., without parallelization using sct_run_batch) with ROIs/labels defined by yml file: +# extract_normative_metrics.py +# -path-data ~/data-multi-subject_results +# -sub sub-amu01 +# -yml-file labels_to_process.yml # # Authors: Jan Valosek, Julien Cohen-Adad -# ------------------------------------------------------- +# import os import sys diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index 9227eea..29eb098 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -1,9 +1,10 @@ #!/usr/bin/env python + # -# Generate figures and statistics for individual qMRI metrics (FA, MD, AD, RD, MTR, MTsat) for different labels/ROIs -# (SC, WM, GM, ...) along individual cervical levels (C2, C3, C4, C5) pervendor and persite +# Generate figures and compute statistics for individual qMRI metrics (FA, MD, AD, RD, MTR, MTsat) for different +# labels/ROIs (SC, WM, GM, ...) along individual cervical levels (C2, C3, C4, C5) pervendor and persite # -# USAGE (run this script in the directory with perlevel *csv files, i.e. "results/perlevel" directory): +# USAGE: # # python generate_figures.py # -path-results ~/spineGeneric-multi-subject_results/results/perlevel @@ -11,12 +12,13 @@ # -participants-file ~/spineGeneric-multi-subject_results/results/participants.tsv # # Input arguments: -# -path-results - directory with *.csv files -# -config - input yml config file with subjects to exclude (e.g., due to back data quality) +# -path-results - directory with perlevel *.csv files (computed by extract_normative_metrics.py script) +# -config - input yml config file with subjects to exclude (e.g., due to bad data quality, noise, ...) # -participants-file - input .tsv file with participants characteristics (sex, age, ...) # # Inspired by - https://github.com/sct-pipeline/spine-generic/blob/master/processing/generate_figure.py # Authors: Jan Valosek, Julien Cohen-Adad +# # TODO - combine this script (and probably also whole repo) with spine-generic repo From 89505e2fee7197bb0b7dc680ea6ab83f854e906b Mon Sep 17 00:00:00 2001 From: valosekj Date: Mon, 5 Apr 2021 09:21:20 +0200 Subject: [PATCH 08/10] add two blank lines between each function --- scripts/generate_figures.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index 29eb098..ab67e03 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -151,6 +151,7 @@ TICKSIZE = 10 LABELSIZE = 15 + # TODO - modify this function to save metrics for individual ROI and levels def aggregate_per_site(dict_results, metric, dict_exclude_subj, path_participants): """ @@ -291,6 +292,7 @@ def aggregate_age_and_sex_per_vendor(path_participants, subjects_processed): return df_age, df_sex + def summary_per_vendor(df, metric): """ Compute mean, sd and cov values pervendor (Siemens, GE, Philips) for individual labels/ROIs (SC, WM, GM, ...) @@ -391,6 +393,7 @@ def summary_per_vendor(df, metric): return df_vendor_mean, df_vendor_sd, df_vendor_mean_and_sd, df_vendor_cov, df_summary_vendor + def generate_level_evolution_persite(df, df_summary_vendor, metric, path_output): """ Generate figure for each metric - level evolution (C2, C3, C4, C5) per ROI for individual sites @@ -478,6 +481,7 @@ def generate_level_evolution_persite(df, df_summary_vendor, metric, path_output) # plt.show() + def generate_level_evolution_pervendor(df_vendor, df_summary_vendor, metric, path_output): """ Generate figure for each metric - level evolution (C2, C3, C4, C5) per ROI for individual vendors @@ -587,6 +591,7 @@ def generate_level_evolution_pervendor(df_vendor, df_summary_vendor, metric, pat plt.savefig(fname_fig, dpi=200) logger.info('\nCreated: ' + fname_fig) + def format_pvalue(p_value, alpha=0.05, include_equal=True): """ If p-value is lower than 0.05, change it to "<0.05", otherwise, round it to two decimals @@ -645,6 +650,7 @@ def load_participants_file(path_participants): return participants_df + def fetch_subject(filename): """ Get subject ID from filename @@ -655,6 +661,7 @@ def fetch_subject(filename): subject = path.split(os.sep)[-2] return subject + def remove_subject(subject, metric, dict_exclude_subj): """ Check if subject should be removed @@ -672,6 +679,7 @@ def remove_subject(subject, metric, dict_exclude_subj): return True return False + def get_parameters(): parser = argparse.ArgumentParser( description="Generate figures. This script needs to be run within the folder with *.csv " @@ -698,6 +706,7 @@ def get_parameters(): args = parser.parse_args() return args + def main(): args = get_parameters() From 659244fc59d17def13aae1664c27b439d1f41853 Mon Sep 17 00:00:00 2001 From: valosekj Date: Mon, 5 Apr 2021 09:22:23 +0200 Subject: [PATCH 09/10] create directories figures and tables where outputs are saved --- scripts/generate_figures.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index ab67e03..881192f 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -475,7 +475,7 @@ def generate_level_evolution_persite(df, df_summary_vendor, metric, path_output) fig.tight_layout() fig.subplots_adjust(top=0.88) # save figure - fname_fig = os.path.join(path_output, metric + '_per_sites.png') + fname_fig = os.path.join(path_output, 'figures', metric + '_per_sites.png') plt.savefig(fname_fig, dpi=200) logger.info('\nCreated: {}\n'.format(fname_fig)) @@ -587,7 +587,7 @@ def generate_level_evolution_pervendor(df_vendor, df_summary_vendor, metric, pat fig.subplots_adjust(top=0.88, bottom=0.1) # save figure - fname_fig = os.path.join(path_output, metric + '_per_vendor.png') + fname_fig = os.path.join(path_output, 'figures', metric + '_per_vendor.png') plt.savefig(fname_fig, dpi=200) logger.info('\nCreated: ' + fname_fig) @@ -743,7 +743,15 @@ def main(): print("-path-results flag has not been set. Assuming current directory as a directory with *csv files.") os.chdir(path_output) - # fetch where is participants.tsv file located + # create directory figures where created figures will be saved + if not os.path.exists(os.path.join(path_output, 'figures')): + os.makedirs(os.path.join(path_output, 'figures')) + + # create directory tables where created tables will be saved + if not os.path.exists(os.path.join(path_output, 'tables')): + os.makedirs(os.path.join(path_output, 'tables')) + + # fetch where participants.tsv file is located if args.participants_file is not None: if os.path.isfile(args.participants_file): path_participants = args.participants_file @@ -796,10 +804,10 @@ def main(): # ------------------------------------------------------------------ df_vendor_mean, df_vendor_sd, df_vendor_mean_and_sd, df_vendor_cov, df_summary_vendor = summary_per_vendor(df, metric) # Save mean_and_sd tables and cov as a .csv files - fname_csv_per_vendor_mean_sd = os.path.join(os.getcwd(), metric) + '_mean_and_sd_per_vendors.csv' + fname_csv_per_vendor_mean_sd = os.path.join(os.getcwd(), 'tables', metric + '_mean_and_sd_per_vendors.csv') df_vendor_mean_and_sd.to_csv(fname_csv_per_vendor_mean_sd) logger.info('\nCreated: {}'.format(fname_csv_per_vendor_mean_sd)) - fname_csv_per_vendor_cov = os.path.join(os.getcwd(), metric) + '_cov_per_vendors.csv' + fname_csv_per_vendor_cov = os.path.join(os.getcwd(), 'tables', metric + '_cov_per_vendors.csv') df_vendor_cov.to_csv(fname_csv_per_vendor_cov) logger.info('\nCreated: {}'.format(fname_csv_per_vendor_cov)) From 425e5e8b7aa0ce6842278b0a122b4cec4bcdabb5 Mon Sep 17 00:00:00 2001 From: valosekj Date: Mon, 5 Apr 2021 09:22:38 +0200 Subject: [PATCH 10/10] fix comments --- scripts/generate_figures.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/generate_figures.py b/scripts/generate_figures.py index 881192f..b56b576 100644 --- a/scripts/generate_figures.py +++ b/scripts/generate_figures.py @@ -729,7 +729,7 @@ def main(): # initialize empty dict if no config yml file is passed dict_exclude_subj = dict() - # change directory to where are .csv files are located (and where figures will be generated) + # change directory to where are perlevel *.csv files located if args.path_results is not None: if os.path.isdir(args.path_results): path_output = args.path_results @@ -738,7 +738,7 @@ def main(): else: raise FileNotFoundError("Directory '{}' was not found.".format(args.path_results)) else: - # Stay in current directory (assuming it is results directory) + # stay in the current directory (assuming it is results directory) path_output = os.getcwd() print("-path-results flag has not been set. Assuming current directory as a directory with *csv files.") os.chdir(path_output) @@ -758,7 +758,7 @@ def main(): else: raise FileNotFoundError("Participants file '{}' was not found.".format(args.participants_file)) else: - # if not passsed, assuming it is located in same dir as a *csv files + # if participants.tsv is not passsed, assuming it is located in same dir as a *csv files path_participants = os.path.join(os.getcwd(), 'participants.tsv') # fetch perlevel .csv files @@ -768,7 +768,7 @@ def main(): raise RuntimeError("No *.csv files were found in the current directory. You can specify directory with *.csv " "files by -path-results flag.") - # Dump log file there + # dump log file there if os.path.exists(FNAME_LOG): os.remove(FNAME_LOG) fh = logging.FileHandler(os.path.join(os.path.abspath(os.curdir), FNAME_LOG))