Skip to content

Commit

Permalink
moved euler to group2
Browse files Browse the repository at this point in the history
  • Loading branch information
fliem committed Nov 29, 2017
1 parent 8075f5c commit 5e88af0
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def run(command, env={}, ignore_errors=False):
'Multiple participant level analyses can be run independently '
'(in parallel) using the same output_dir. '
'"group1" creates study specific group template. '
'"group2" exports group stats tables for cortical parcellation and subcortical segmentation.'
'"group3" exports euler numbers.',
choices=['participant', 'group1', 'group2', 'group3'])
'"group2" exports group stats tables for cortical parcellation, subcortical segmentation '
'a table with euler numbers.',
choices=['participant', 'group1', 'group2'])
parser.add_argument('--participant_label', help='The label of the participant that should be analyzed. The label '
'corresponds to sub-<participant_label> from the BIDS spec '
'(so it does not include "sub-"). If this parameter is not '
Expand Down Expand Up @@ -492,13 +492,11 @@ def run(command, env={}, ignore_errors=False):
print("\nTable export finished for %d subjects/sessions." % len(subjects))

else:
print("\nNo subjects included in the analysis. Skipping group2 level.")
print("\nNo subjects included in the analysis. Skipping group2 level stats tables.")


elif args.analysis_level == "group3": # extract euler number
# This extracts the euler numbers for the orig.nofix surfaces from the recon-all.log file
# see Rosen et al. (2017), https://www.biorxiv.org/content/early/2017/10/01/125161

def extract_euler(logfile):
with open(logfile) as fi:
logtext = fi.read()
Expand All @@ -509,10 +507,9 @@ def extract_euler(logfile):
lh_euler, rh_euler = results[0]
return int(lh_euler), int(rh_euler)

euler_out_path = os.path.join(output_dir, "00_group3_quality")
if not os.path.isdir(euler_out_path):
os.makedirs(euler_out_path)
euler_out_file = os.path.join(euler_out_path, "euler.tsv")


euler_out_file = os.path.join(table_dir, "euler.tsv")
print("Writing euler tables to %s." % euler_out_file)

# get freesurfer subjects
Expand All @@ -534,6 +531,7 @@ def extract_euler(logfile):
columns=["subject", "lh_euler", "rh_euler"])
df = df.append(df_subject)
df["mean_euler_bh"] = df[["lh_euler", "rh_euler"]].mean(1)
df.sort_values("subject", inplace=True)
df.to_csv(euler_out_file, sep="\t", index=False)
else:
print("\nNo subjects included in the analysis. Skipping group3 level.")
print("\nNo subjects included in the analysis. Skipping group2 level euler number table.")

0 comments on commit 5e88af0

Please sign in to comment.