coganlab / GlobalLocal

The Global Local task code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

loaded data does not save to save_dir

jimzhang629 opened this issue · comments

On the jim branch, in copy_wavelet_spec.ipynb, the following code does not save loaded GlobalLocal data to the save_dir directory.
`HOME = os.path.expanduser("~")

HOME = '/Users/jinjiang-macair/Library/CloudStorage'

if 'SLURM_ARRAY_TASK_ID' in os.environ.keys():
LAB_root = os.path.join(HOME, "workspace", "CoganLab")
layout = get_data("GlobalLocal", root=LAB_root)
subjects = list(int(os.environ['SLURM_ARRAY_TASK_ID']))
else: # if not then set box directory
LAB_root = os.path.join(HOME, "Box-Box", "CoganLab") #it's just Box for windows, but on Mac it's Box-Box
layout = get_data("GlobalLocal", root=LAB_root)
subjects = layout.get(return_type="id", target="subject")

for sub in subjects:
if sub != "D0022":
continue

filt = raw_from_layout(layout.derivatives['clean'], subject=sub,
                       extension='.edf', desc='clean', preload=False)
print(filt)
# fix SentenceRep events
from events import fix_annotations  # noqa E402
new = crop_empty_data(filt,)

good = new.copy()
fix_annotations(good)

# good.drop_channels(good.info['bads'])
good.info['bads'] = channel_outlier_marker(good, 3, 2)
good.drop_channels(good.info['bads'])
# good.info['bads'] += channel_outlier_marker(good, 4, 2)
# good.drop_channels(good.info['bads'])
good.load_data()

ch_type = filt.get_channel_types(only_data_chs=True)[0]
good.set_eeg_reference(ref_channels="average", ch_type=ch_type)

# Remove intermediates from mem
del new
# good.plot()

## epoching and trial outlier removal

save_dir = os.path.join(layout.root, 'derivatives', 'spec', 'wavelet', sub)
if not os.path.exists(save_dir):
    os.makedirs(save_dir)`

I fixed the code in the latest commit (c99192f). Runs fine on my computer so let me know about yours.