def readme_file(outdir): """ Create README file if it does not exist. If it exists, do nothing. Parameters ---------- outdir: path Full path to the output directory. """ file_path = os.path.join(outdir, 'README.md') if not os.path.exists(file_path): text = 'Empty README, please fill in describing the dataset in more detail.' LGR.warning('phys2bids could not find README,' 'generating it EMPTY, please fill in the necessary info') utils.writefile(file_path, '', text)
def print_summary(filename, ntp_expected, ntp_found, samp_freq, time_offset, outfile): """ Print a summary onscreen and in file with informations on the files. Parameters ---------- filename: str Name of the input of phys2bids. ntp_expected: int Number of expected timepoints, as defined by user. ntp_found: int Number of timepoints found with the automatic process. samp_freq: float Frequency of sampling for the output file. time_offset: float Difference between beginning of file and first TR. outfile: str or path Fullpath to output file. Notes ----- Outcome: summary: str Prints the summary on screen outfile: .log file File containing summary """ start_time = -time_offset summary = (f'\n------------------------------------------------\n' f'Filename: {filename}\n' f'\n' f'Timepoints expected: {ntp_expected}\n' f'Timepoints found: {ntp_found}\n' f'Sampling Frequency: {samp_freq} Hz\n' f'Sampling started at: {start_time} s\n' f'Tip: Time 0 is the time of first trigger\n' f'------------------------------------------------\n') LGR.info(summary) utils.writefile(outfile, '.log', summary)
def test_writefile(tmpdir): ext = '.txt' test_old_path = tmpdir.join('foo.txt') test_text = 'Wubba lubba dub dub!' utils.writefile(test_old_path, ext, test_text)