Exemple #1
0
try:
    json_file = sys.argv[2]
    print("USING:", json_file)
except:
    json_file = "settings.json"
    print("USING:", json_file)

# opening a json file
with open(json_file) as pipeline_file:
    parameters = json.load(pipeline_file)

path = parameters["dataset_path"]
sfreq = parameters["downsample_dataset"]
sub_path = op.join(path, "data")
der_path = op.join(path, "derivatives")
files.make_folder(der_path)
proc_path = op.join(der_path, "processed")
files.make_folder(proc_path)

subjects = files.get_folders_files(sub_path)[0]
subjects.sort()
subject = subjects[index]
subject_id = subject.split("/")[-1]

meg_path = op.join(subject, "ses-01", "meg")

sub_path = op.join(proc_path, subject_id)
files.make_folder(sub_path)

dss = files.get_folders_files(meg_path)[0]
dss = [i for i in dss if "ds" in i]
json_key_file = "keys/keys.json"
with open(json_key_file) as key_file:
    params = json.load(key_file)

json_vid_file = "video_analysis_params.json"
with open(json_vid_file) as vid_json:
    analysis = json.load(vid_json)

os.environ["INDICO_APP_KEY"] = params["indico"]
os.environ["CLARIFAI_API_KEY"] = params["clarifai"]
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = params["google"]

vid_file = analysis["video_path"]

files.make_folder("data")

if analysis["frames_no"] == 0:
    video = cv2.VideoCapture(vid_file)
    total_frames = 0
    while True:
        (grab, frame) = video.read()
        if not grab:
            break
        
        total_frames += 1
    video.release()
    cv2.destroyAllWindows()

    misc.update_key_value(json_vid_file, "frames_no", total_frames)
Exemple #3
0
    print("USING:", json_file)
except:
    json_file = "settings.json"
    print("USING:", json_file)

# opening a json file
with open(json_file) as pipeline_file:
    parameters = json.load(pipeline_file)

path = parameters["dataset_path"]
sfreq = parameters["downsample_dataset"]
hi_pass = parameters["hi_pass_filter"]
sub_path = op.join(path, "data")

der_path = op.join(path, "derivatives")
files.make_folder(der_path)
proc_path = op.join(der_path, "processed")
files.make_folder(proc_path)

subjects = files.get_folders_files(proc_path)[0]
subjects.sort()
subject = subjects[index]
subject_id = subject.split(sep)[-1]

sub_path = op.join(proc_path, subject_id)
files.make_folder(sub_path)

qc_folder = op.join(sub_path, "QC")
files.make_folder(qc_folder)

epo_paths = files.get_files(sub_path, "sub", "-epo.fif")[2]
Exemple #4
0
    json_file = "settings.json"
    print("USING:", json_file)

start_time = time.time()

# opening a json file
with open(json_file) as pipeline_file:
    parameters = json.load(pipeline_file)

path = parameters["dataset_path"]
sfreq = parameters["downsample_dataset"]
hi_pass = parameters["hi_pass_filter"]
sub_path = op.join(path, "data")

der_path = op.join(path, "derivatives")
files.make_folder(der_path)
proc_path = op.join(der_path, "processed")
files.make_folder(proc_path)

subjects = files.get_folders_files(proc_path)[0]
subjects.sort()
subject = subjects[index]
subject_id = subject.split("/")[-1]

sub_path = op.join(proc_path, subject_id)
files.make_folder(sub_path)

#setting the paths and extracting files
slt_mot_paths  = [i for i in files.get_folders_files(sub_path)[0] if "motor" in i]
slt_vis_paths = [i for i in files.get_folders_files(sub_path)[0] if "visual" in i]
epo_mot_paths  = files.get_files(sub_path, "sub", "motor-epo.fif")[2]
    print("USING:", json_file)

# opening a json file
with open(json_file) as pipeline_file:
    parameters = json.load(pipeline_file)


def split_and_eval(x):
    return [eval(i) for i in x.split(",")]


path = parameters["dataset_path"]
sfreq = parameters["downsample_dataset"]

der_path = op.join(path, "derivatives")
files.make_folder(der_path)
proc_path = op.join(der_path, "processed")
files.make_folder(proc_path)

subjects = files.get_folders_files(proc_path)[0]
subjects.sort()
subject = subjects[index]
subject_id = subject.split("/")[-1]
print(subject)

raw_meg_dir = op.join(path, "data")
raw_meg_path = op.join(raw_meg_dir, subject_id, "ses-01", "meg")
ds_paths = files.get_folders_files(raw_meg_path)[0]
ds_paths = [i for i in ds_paths if "misc" not in i]
ds_paths.sort()
res4_paths = [files.get_files(i, "", ".res4")[2][0] for i in ds_paths]

def norm_vec(vec):
    """
    returns unit vector
    """
    mag = np.sqrt((vec[0]**2 + vec[1]**2 + vec[2]**2))
    unit_vector = np.array([vec[0] / mag, vec[1] / mag, vec[2] / mag])
    return unit_vector


path = parameters["dataset_path"]
sfreq = parameters["downsample_head"]
sub_path = op.join(path, "data")
der_path = op.join(path, "derivatives")
files.make_folder(der_path)
head_path = op.join(der_path, "head_motion")
files.make_folder(head_path)

subjects = files.get_folders_files(sub_path)[0]
subject = subjects[index]
subject_id = subject.split("/")[-1]

meg_path = op.join(subject, "ses-01", "meg")

dss = files.get_folders_files(meg_path)[0]
dss = [i for i in dss if "ds" in i]
dss.sort()

for ds in dss:
    print("PRINT:", ds)