cvnlab / GLMsingle

A toolbox for accurate single-trial estimates in fMRI time-series data
BSD 3-Clause "New" or "Revised" License
101 stars 45 forks source link

if outputdir is None, why we still create a directory #155

Open yibeichan opened 1 month ago

yibeichan commented 1 month ago

Hi,

I notice that when i use 2D brain data (cifti), there is no figured generated. I guess that's reasonable since it's not easy to plot surface region if no additional information given. but I don't understand the logic here:

        if figuredir is not None:
            wantfig = 1  # if outputdir is not None, we want figures
        else:
            wantfig = 0

        # deal with output directory
        if outputdir is None:
            cwd = os.getcwd()
            outputdir = os.path.join(cwd, 'GLMestimatesingletrialoutputs')

if outputdir is None then wantfig = 0, why we still create a directory? this will cause problems when we run each session separately, the figure folder will always generated at cwd (where the code file is), and once the folder is generated for one session, the following sessions will have "FileExistsError".

the "FileExistsError" can be solved by adding an extra function to remove the folder everytime, just want to double check whether "if outputdir is None then wantfig = 0, and still create a directory" is the logic you prefer.

thanks!

yibeichan commented 1 month ago

oh, i saw this

if os.path.exists(figuredir):
    import shutil
    shutil.rmtree(figuredir)
    os.makedirs(figuredir)
else:
    os.makedirs(figuredir)

but it's still a problem when running things parallel + slurm...