forked from razvanmarinescu/brain-coloring
-
Notifications
You must be signed in to change notification settings - Fork 1
/
csv2movie.py
63 lines (41 loc) · 1.46 KB
/
csv2movie.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from os import sep
from numpy.lib.shape_base import split
import pandas as pd
import numpy as np
from config import *
INPUT = pd.read_csv('./input/mouse_template.csv')
template_location = './input/movie_template.csv' # where the generated movie csv data goes
ATLAS = 'Mice' # specify the Atlas you are using
columns = INPUT.columns[1:].tolist()
# print(columns)
rows = []
inputData = INPUT.values
# add zero matrix as initial value
# this increments into the first value
keepZeros = False
biomarkerData = []
if keepZeros:
biomarkerData = np.zeros(len(inputData[0]) - 1, dtype = int).tolist()
biomarkerData = [biomarkerData]
for i in inputData:
biomarkerData.append(i[1:].tolist())
iter = 0
nrFrames = 8 # number of frames per data point
movieData = []
nrFrames-=1
for sub in range(len(biomarkerData) - 1):
for count in range(int(nrFrames) + 1):
split_data = []
for i in range(len(columns)):
number = biomarkerData[sub+1][i] - biomarkerData[sub][i]
delta_change = count * (number/nrFrames)
new_data_point = biomarkerData[sub][i] + delta_change
split_data.append(new_data_point)
count+=1
movieData.append(split_data)
print(count)
for i in range(len(movieData)):
rows.append('Image_' + str(i))
movieData = pd.DataFrame(movieData, columns = columns, index = rows)
print(movieData)
movieData.to_csv(template_location, index=True, index_label='Image-name-unique')