diff --git a/narps_open/pipelines/team_C88N.py b/narps_open/pipelines/team_C88N.py index f3613216..da6ee77a 100755 --- a/narps_open/pipelines/team_C88N.py +++ b/narps_open/pipelines/team_C88N.py @@ -378,6 +378,33 @@ def get_subject_level_analysis(self): return l1_analysis + def get_subject_level_outputs(self): + """ Return the names of the files the subject level analysis is supposed to generate. """ + + # Contrat maps + templates = [join( + self.directories.output_dir, + 'l1_analysis', '_subject_id_{subject_id}', f'con_{contrast_id}.nii')\ + for contrast_id in self.contrast_list] + + # SPM.mat file + templates += [join( + self.directories.output_dir, + 'l1_analysis', '_subject_id_{subject_id}', 'SPM.mat')] + + # spmT maps + templates += [join( + self.directories.output_dir, + 'l1_analysis', '_subject_id_{subject_id}', f'spmT_{contrast_id}.nii')\ + for contrast_id in self.contrast_list] + + # Format with subject_ids + return_list = [] + for template in templates: + return_list += [template.format(subject_id = s) for s in self.subject_list] + + return return_list + # @staticmethod # Starting python 3.10, staticmethod should be used here # Otherwise it produces a TypeError: 'staticmethod' object is not callable def get_subset_contrasts(file_list, subject_list, participants_file): @@ -413,72 +440,6 @@ def get_subset_contrasts(file_list, subject_list, participants_file): return equal_indifference_id, equal_range_id, equal_indifference_files, equal_range_files - # @staticmethod # Starting python 3.10, staticmethod should be used here - # Otherwise it produces a TypeError: 'staticmethod' object is not callable - def reorganize_results(team_id, nb_sub, output_dir, results_dir): - """ Reorganize the results to analyze them. - - Parameters: - - results_dir: str, directory where results will be stored - - output_dir: str, name of the sub-directory for final results - - nb_sub: float, number of subject used for the analysis - - team_id: str, ID of the team to reorganize results - """ - from os import mkdir - from os.path import join, isdir - from shutil import copyfile - - hypotheses = [ - join(output_dir, - f'l2_analysis_equalIndifference_nsub_{nb_sub}', '_contrast_id_1_model_type_gain'), - join(output_dir, - f'l2_analysis_equalRange_nsub_{nb_sub}', '_contrast_id_1_model_type_gain'), - join(output_dir, - f'l2_analysis_equalIndifference_nsub_{nb_sub}', '_contrast_id_1_model_type_gain'), - join(output_dir, - f'l2_analysis_equalRange_nsub_{nb_sub}', '_contrast_id_1_model_type_gain'), - join(output_dir, - f'l2_analysis_equalIndifference_nsub_{nb_sub}', '_contrast_id_1_model_type_loss'), - join(output_dir, - f'l2_analysis_equalRange_nsub_{nb_sub}', '_contrast_id_1_model_type_loss'), - join(output_dir, - f'l2_analysis_equalIndifference_nsub_{nb_sub}', '_contrast_id_1_model_type_loss'), - join(output_dir, - f'l2_analysis_equalRange_nsub_{nb_sub}', '_contrast_id_1_model_type_loss'), - join(output_dir, - f'l2_analysis_groupComp_nsub_{nb_sub}', '_contrast_id_1_model_type_loss') - ] - - # Build lists of files for unthresholded and thresholded maps - repro_unthresh = [] - repro_thresh = [] - for file_id, filename in enumerate(hypotheses): - if file_id in [4,5]: - repro_unthresh.append(join(filename, 'spmT_0002.nii')) - repro_thresh.append(join(filename, '_threshold1', 'spmT_0002_thr.nii')) - else: - repro_unthresh.append(join(filename, 'spmT_0001.nii')) - repro_thresh.append(join(filename, '_threshold0', 'spmT_0001_thr.nii')) - - if not isdir(join(results_dir, "NARPS-reproduction")): - mkdir(join(results_dir, "NARPS-reproduction")) - - for file_id, filename in enumerate(repro_unthresh): - f_in = filename - f_out = join(results_dir, - 'NARPS-reproduction', - f'team_{team_id}_nsub_{nb_sub}_hypo{file_id + 1}_unthresholded.nii') - copyfile(f_in, f_out) - - for file_id, filename in enumerate(repro_thresh): - f_in = filename - f_out = join(results_dir, - 'NARPS-reproduction', - f'team_{team_id}_nsub_{nb_sub}_hypo{file_id + 1}_thresholded.nii') - copyfile(f_in, f_out) - - print(f'Results files of team {team_id} reorganized.') - def get_group_level_analysis(self): """ Return all workflows for the group level analysis.