Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hypothalamus_light_7TfMRI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GIGA-CRC Human Imaging
Public
FASST
Hypothalamus_light_7TfMRI
Commits
01f3f4bb
Commit
01f3f4bb
authored
9 months ago
by
Vandewalle Gilles
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
b4c9bf5f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
behavior_onsets/Emo_LM_per_illuminance.m
+343
-0
343 additions, 0 deletions
behavior_onsets/Emo_LM_per_illuminance.m
with
343 additions
and
0 deletions
behavior_onsets/Emo_LM_per_illuminance.m
0 → 100644
+
343
−
0
View file @
01f3f4bb
%% Extracting Stimulation Onsets (Task and Light Inputs) of the Emo Task
% This code extracts the onsets under different light conditions(3 Blue conditions, Orange, Dark)
% VERSION_07 :
% Output of this version:
% Emo_B1 Emo_B2, Emo_B3, Emo_O, Emo_D
% Neut_B1, Neut_B2, Neut_B3, Neut_O, Neut_D
function
Emo_LM_v05
(
modul
,
check
,
paths
,
subs_info
,
H
)
%modul = 1 to include a parametric modulation according to light intensity
if
isempty
(
subs_info
)
==
1
return
end
%% Define parameters and sbj file
TR
=
2340
;
% TR of the scan in ms
LM_dir
=
'LM'
;
% folder's name containing all log manager files.
%%
for
id
=
1
:
size
(
subs_info
,
1
)
cd
(
paths
.
data
);
subject_info
=
char
(
subs_info
(
id
));
subject_ID
=
subject_info
(
5
:
7
);
switch
subject_info
(
13
)
case
'm'
subject_session
=
'M'
;
case
'e'
subject_session
=
'E'
;
end
entry_table
=
[
'HILIGHT_'
,
subject_ID
'_'
subject_session
]
;
index
=
strcmp
(
H
.
subject_Ids
,
entry_table
)
;
patient_data
=
H
(
index
,:)
;
% inform on the status of the analysis and load the correspondent log file
disp
([
'Processing subject '
subject_ID
]);
cd
(
strcat
(
subject_info
,
'/'
,
LM_dir
));
file
=
strcat
(
'HL_E_'
,
subject_ID
,
'_forLM.csv'
);
% name of log file have to be consistent
% if no log file return a warning
if
isempty
(
file
)
warning
([
'No logfile found for N-back task of subject '
subject_ID
])
return
end
%retrieve info from the log file
T
=
readtable
(
char
(
file
));
% read the .csv file
% Get when the experiment started
start
=
unique
(
T
.
time_Pygaze_start_recording
);
start_exp
=
str2double
(
start
(
1
));
% Get type of Sound (emotional or neutral) and time of appearance
Type
=
T
.
Sound
;
ind_nan
=
strcmp
(
Type
,
'NA'
);
Type
(
ind_nan
)
=
[];
Type
=
char
(
Type
);
Soun_app
=
T
.
time_Sound_app
(
5
:
end
,:);
ind_neutral
=
'N'
==
Type
(:,
1
);
ind_emotion
=
'A'
==
Type
(:,
1
);
Tps_neutral
=
(
str2double
(
Soun_app
(
ind_neutral
))
-
start_exp
)/
TR
;
%time expressed in scans
Tps_emotion
=
(
str2double
(
Soun_app
(
ind_emotion
))
-
start_exp
)/
TR
;
%time expressed in scans
All_tps
=
zeros
(
length
(
Type
),
1
);
All_tps
(
ind_neutral
,:)
=
Tps_neutral
;
All_tps
(
ind_emotion
,:)
=
Tps_emotion
;
%%%%%%%%%%%%%% Get light condition and duration
light_changes
=
find
(
abs
(
any
(
diff
(
char
(
T
.
Light_Condition
)),
2
))
>
0
);
% Preallocate array with 2 columns (start and duration) for each light
% cond
light_start_dur
=
struct
();
countb
=
0
;
counto
=
0
;
countd
=
0
;
for
lights
=
1
:
length
(
light_changes
)
curr_cond
=
T
.
Light_Condition
{
light_changes
(
lights
)
+
1
};
curr_light
=
curr_cond
(
1
);
if
strcmp
(
curr_light
,
'B'
)
==
1
countb
=
countb
+
1
;
thecount
=
countb
;
else
counto
=
counto
+
1
;
thecount
=
counto
;
end
curr_int
=
curr_cond
(
2
);
curr_loop
=
curr_cond
(
3
);
countd
=
countd
+
1
;
% Start calculating light/dark onsets and durations
light_start_dur
.
(
curr_light
)
.
onset
(
thecount
)
=
(
str2double
...
(
T
.
time_Light_Loop_Sequence
(
light_changes
(
lights
)
+
1
))
-
start_exp
)/
TR
;
dark_on
=
unique
(
T
.
(
sprintf
(
'time_%s%sD%s_inner_loop'
,
curr_light
,
curr_int
,
curr_loop
)));
light_start_dur
.
D
.
onset
(
countd
)
=
(
str2double
(
dark_on
(
1
))
-
start_exp
)/
TR
;
light_start_dur
.
(
curr_light
)
.
endLight
(
thecount
)
=
light_start_dur
.
D
.
onset
(
countd
);
light_start_dur
.
(
curr_light
)
.
duration
(
thecount
)
=
(
light_start_dur
.
D
.
onset
...
(
countd
)
-
light_start_dur
.
(
curr_light
)
.
onset
(
thecount
));
light_start_dur
.
(
curr_light
)
.
names
(
thecount
)
=
{
curr_cond
};
if
exist
(
'curr_dark'
,
'var'
)
==
1
index_lastDark
=
strcmp
(
light_start_dur
.
D
.
names
,
curr_dark
);
lastDark
=
light_start_dur
.
D
.
onset
(
index_lastDark
);
light_start_dur
.
D
.
duration
(
index_lastDark
)
=
light_start_dur
.
(
curr_light
)
.
onset
(
thecount
)
-
lastDark
;
light_start_dur
.
D
.
endLight
(
index_lastDark
)
=
light_start_dur
.
(
curr_light
)
.
onset
(
thecount
);
end
curr_dark
=
sprintf
(
'%s%sD%s'
,
curr_light
,
curr_int
,
curr_loop
);
light_start_dur
.
D
.
names
(
countd
)
=
{
curr_dark
};
end
%%%%%%%%%% Seperation of Blue Light Intensities
start_light_6Con
=
struct
();
countB1
=
0
;
countB2
=
0
;
countB3
=
0
;
for
ii
=
1
:
length
(
light_start_dur
.
B
.
names
)
if
contains
(
light_start_dur
.
B
.
names
(
ii
),
'B1'
)
countB1
=
countB1
+
1
;
start_light_6Con
.
B1
.
onset
(
countB1
)
=
light_start_dur
.
B
.
onset
(
ii
);
start_light_6Con
.
B1
.
duration
(
countB1
)
=
light_start_dur
.
B
.
duration
(
ii
);
start_light_6Con
.
B1
.
names
(
countB1
)
=
light_start_dur
.
B
.
names
(
ii
);
start_light_6Con
.
B1
.
endLight
(
countB1
)
=
light_start_dur
.
B
.
endLight
(
ii
);
elseif
contains
(
light_start_dur
.
B
.
names
(
ii
),
'B2'
)
countB2
=
countB2
+
1
;
start_light_6Con
.
B2
.
onset
(
countB2
)
=
light_start_dur
.
B
.
onset
(
ii
);
start_light_6Con
.
B2
.
duration
(
countB2
)
=
light_start_dur
.
B
.
duration
(
ii
);
start_light_6Con
.
B2
.
names
(
countB2
)
=
light_start_dur
.
B
.
names
(
ii
);
start_light_6Con
.
B2
.
endLight
(
countB2
)
=
light_start_dur
.
B
.
endLight
(
ii
);
elseif
contains
(
light_start_dur
.
B
.
names
(
ii
),
'B3'
)
countB3
=
countB3
+
1
;
start_light_6Con
.
B3
.
onset
(
countB3
)
=
light_start_dur
.
B
.
onset
(
ii
);
start_light_6Con
.
B3
.
duration
(
countB3
)
=
light_start_dur
.
B
.
duration
(
ii
);
start_light_6Con
.
B3
.
names
(
countB3
)
=
light_start_dur
.
B
.
names
(
ii
);
start_light_6Con
.
B3
.
endLight
(
countB3
)
=
light_start_dur
.
B
.
endLight
(
ii
);
end
end
start_light_6Con
.
O
=
light_start_dur
.
O
;
start_light_6Con
.
D
=
light_start_dur
.
D
;
%%%%%%%%%%%%%%%%%%%%%
% Take Emotional and Neutral sounds appearing during one of each
% condition
type_lights
=
{
'B'
,
'O'
,
'D'
};
sounds_in_cond
=
struct
();
for
curr_light
=
1
:
length
(
type_lights
)
temp
=
light_start_dur
.
(
type_lights
{
curr_light
});
count_em
=
0
;
count_neutr
=
0
;
for
temp_size
=
1
:
length
(
temp
.
onset
)
for
emot
=
1
:
length
(
Tps_emotion
)
if
curr_light
==
3
&&
temp_size
==
20
if
Tps_emotion
(
emot
)
>
temp
.
onset
(
temp_size
)
count_em
=
count_em
+
1
;
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
emotional
(
count_em
)
=
Tps_emotion
(
emot
);
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
indexEm
(
count_em
)
=
find
(
All_tps
==
Tps_emotion
(
emot
));
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
names
(
count_em
)
=
(
temp
.
names
(
temp_size
));
end
else
if
Tps_emotion
(
emot
)
>
temp
.
onset
(
temp_size
)
&&
Tps_emotion
(
emot
)
<
temp
.
endLight
(
temp_size
)
count_em
=
count_em
+
1
;
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
emotional
(
count_em
)
=
Tps_emotion
(
emot
);
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
indexEm
(
count_em
)
=
find
(
All_tps
==
Tps_emotion
(
emot
));
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
names
(
count_em
)
=
(
temp
.
names
(
temp_size
));
end
end
end
for
neut
=
1
:
length
(
Tps_neutral
)
if
curr_light
==
3
&&
temp_size
==
20
if
Tps_neutral
(
neut
)
>
temp
.
onset
(
temp_size
)
count_neutr
=
count_neutr
+
1
;
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
neutral
(
count_neutr
)
=
Tps_neutral
(
neut
);
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
indexNe
(
count_neutr
)
=
find
(
All_tps
==
Tps_neutral
(
neut
));
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
names
(
count_neutr
)
=
(
temp
.
names
(
temp_size
));
end
else
if
Tps_neutral
(
neut
)
>
temp
.
onset
(
temp_size
)
&&
Tps_neutral
(
neut
)
<
temp
.
endLight
(
temp_size
)
count_neutr
=
count_neutr
+
1
;
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
neutral
(
count_neutr
)
=
Tps_neutral
(
neut
);
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
indexNe
(
count_neutr
)
=
find
(
All_tps
==
Tps_neutral
(
neut
));
sounds_in_cond
.
(
type_lights
{
curr_light
})
.
names
(
count_neutr
)
=
(
temp
.
names
(
temp_size
));
end
end
end
end
end
%%% Seperation of sounds by blue light intensities %%%
Sounds_6Con
=
struct
();
countSB1
=
0
;
countSB2
=
0
;
countSB3
=
0
;
for
ii
=
1
:
length
(
sounds_in_cond
.
B
.
names
)
if
contains
(
sounds_in_cond
.
B
.
names
(
ii
),
'B1'
)
countSB1
=
countSB1
+
1
;
Sounds_6Con
.
B1
.
emotional
(
countSB1
)
=
sounds_in_cond
.
B
.
emotional
(
ii
);
Sounds_6Con
.
B1
.
indexEm
(
countSB1
)
=
sounds_in_cond
.
B
.
indexEm
(
ii
);
Sounds_6Con
.
B1
.
neutral
(
countSB1
)
=
sounds_in_cond
.
B
.
neutral
(
ii
);
Sounds_6Con
.
B1
.
indexNe
(
countSB1
)
=
sounds_in_cond
.
B
.
indexNe
(
ii
);
Sounds_6Con
.
B1
.
names
(
countSB1
)
=
sounds_in_cond
.
B
.
names
(
ii
);
elseif
contains
(
sounds_in_cond
.
B
.
names
(
ii
),
'B2'
)
countSB2
=
countSB2
+
1
;
Sounds_6Con
.
B2
.
emotional
(
countSB2
)
=
sounds_in_cond
.
B
.
emotional
(
ii
);
Sounds_6Con
.
B2
.
indexEm
(
countSB2
)
=
sounds_in_cond
.
B
.
indexEm
(
ii
);
Sounds_6Con
.
B2
.
neutral
(
countSB2
)
=
sounds_in_cond
.
B
.
neutral
(
ii
);
Sounds_6Con
.
B2
.
indexNe
(
countSB2
)
=
sounds_in_cond
.
B
.
indexNe
(
ii
);
Sounds_6Con
.
B2
.
names
(
countSB2
)
=
sounds_in_cond
.
B
.
names
(
ii
);
elseif
contains
(
sounds_in_cond
.
B
.
names
(
ii
),
'B3'
)
countSB3
=
countSB3
+
1
;
Sounds_6Con
.
B3
.
emotional
(
countSB3
)
=
sounds_in_cond
.
B
.
emotional
(
ii
);
Sounds_6Con
.
B3
.
indexEm
(
countSB3
)
=
sounds_in_cond
.
B
.
indexEm
(
ii
);
Sounds_6Con
.
B3
.
neutral
(
countSB3
)
=
sounds_in_cond
.
B
.
neutral
(
ii
);
Sounds_6Con
.
B3
.
indexNe
(
countSB3
)
=
sounds_in_cond
.
B
.
indexNe
(
ii
);
Sounds_6Con
.
B3
.
names
(
countSB3
)
=
sounds_in_cond
.
B
.
names
(
ii
);
end
end
Sounds_6Con
.
O
=
sounds_in_cond
.
O
;
Sounds_6Con
.
D
=
sounds_in_cond
.
D
;
%%%%%%% Mel intensity added
mod_B1_sounds
=
zeros
(
length
(
Sounds_6Con
.
B1
.
names
),
1
);
mod_B1_sounds
(
contains
(
Sounds_6Con
.
B1
.
names
,
sprintf
(
'B1'
))
'
)
=
37
;
mod_B2_sounds
=
zeros
(
length
(
Sounds_6Con
.
B2
.
names
),
1
);
mod_B2_sounds
(
contains
(
Sounds_6Con
.
B2
.
names
,
sprintf
(
'B2'
))
'
)
=
92
;
mod_B3_sounds
=
zeros
(
length
(
Sounds_6Con
.
B3
.
names
),
1
);
mod_B3_sounds
(
contains
(
Sounds_6Con
.
B3
.
names
,
sprintf
(
'B3'
))
'
)
=
190
;
mod_O_sounds
=
zeros
(
length
(
Sounds_6Con
.
O
.
names
),
1
);
mod_O_sounds
(
contains
(
Sounds_6Con
.
O
.
names
,
sprintf
(
'O'
))
'
)
=
0.16
;
%%% prepare files for SPM
onsets
=
[{
Sounds_6Con
.
B1
.
emotional
'} {Sounds_6Con.B2.emotional'
}
{
Sounds_6Con
.
B3
.
emotional
'} {Sounds_6Con.O.emotional'
}
...
{
Sounds_6Con
.
D
.
emotional
'
}
...
{
Sounds_6Con
.
B1
.
neutral
'} {Sounds_6Con.B2.neutral'
}
{
Sounds_6Con
.
B3
.
neutral
'} {Sounds_6Con.O.neutral'
}
...
{
Sounds_6Con
.
D
.
neutral
'
}]
durations
=
[{
zeros
(
size
(
Sounds_6Con
.
B1
.
emotional
',1),1)} {zeros(size(Sounds_6Con.B2.emotional'
,
1
),
1
)}
...
{
zeros
(
size
(
Sounds_6Con
.
B3
.
emotional
',1),1)} {zeros(size(Sounds_6Con.O.emotional'
,
1
),
1
)}
...
{
zeros
(
size
(
Sounds_6Con
.
D
.
emotional
'
,
1
),
1
)}
...
{
zeros
(
size
(
Sounds_6Con
.
B1
.
neutral
',1),1)} {zeros(size(Sounds_6Con.B2.neutral'
,
1
),
1
)}
...
{
zeros
(
size
(
Sounds_6Con
.
B3
.
neutral
',1),1)} {zeros(size(Sounds_6Con.O.neutral'
,
1
),
1
)}
...
{
zeros
(
size
(
Sounds_6Con
.
D
.
neutral
'
,
1
),
1
)}];
names
=
[{
'Emo_B1'
}
{
'Emo_B2'
}
{
'Emo_B3'
}
{
'Emo_O'
}
{
'Emo_D'
}
{
'Neut_B1'
}
{
'Neut_B2'
}
...
{
'Neut_B3'
}
{
'Neut_O'
}
{
'Neut_D'
}]
if
modul
==
0
save
(
sprintf
(
'onsets_emo_nomod_Mel_6Con_noblocks_%s.mat'
,
entry_table
),
'onsets'
,
'durations'
,
'names'
);
elseif
modul
==
1
for
x
=
1
:
length
(
names
)
if
x
==
1
pmod
(
x
)
.
name
{
1
}
=
'lightmod_emot_B1'
;
pmod
(
x
)
.
param
{
1
}
=
mod_B1_sounds
'
;
pmod
(
x
)
.
poly
{
1
}
=
1
;
elseif
x
==
2
pmod
(
x
)
.
name
{
1
}
=
'lightmod_emot_B2'
;
pmod
(
x
)
.
param
{
1
}
=
mod_B2_sounds
'
;
pmod
(
x
)
.
poly
{
1
}
=
1
;
elseif
x
==
3
pmod
(
x
)
.
name
{
1
}
=
'lightmod_emot_B3'
;
pmod
(
x
)
.
param
{
1
}
=
mod_B3_sounds
'
;
pmod
(
x
)
.
poly
{
1
}
=
1
;
elseif
x
==
6
pmod
(
x
)
.
name
{
1
}
=
'lightmod_neut_B1'
;
pmod
(
x
)
.
param
{
1
}
=
mod_B1_sounds
'
;
pmod
(
x
)
.
poly
{
1
}
=
1
;
elseif
x
==
7
pmod
(
x
)
.
name
{
1
}
=
'lightmod_neut_B2'
;
pmod
(
x
)
.
param
{
1
}
=
mod_B2_sounds
'
;
pmod
(
x
)
.
poly
{
1
}
=
1
;
elseif
x
==
8
pmod
(
x
)
.
name
{
1
}
=
'lightmod_neut_B3'
;
pmod
(
x
)
.
param
{
1
}
=
mod_B3_sounds
'
;
pmod
(
x
)
.
poly
{
1
}
=
1
;
elseif
x
==
4
pmod
(
x
)
.
name
{
1
}
=
'lightmod_emo_O'
;
pmod
(
x
)
.
param
{
1
}
=
mod_O_sounds
'
;
pmod
(
x
)
.
poly
{
1
}
=
1
;
elseif
x
==
9
pmod
(
x
)
.
name
{
1
}
=
'lightmod_neut_O'
;
pmod
(
x
)
.
param
{
1
}
=
mod_O_sounds
'
;
pmod
(
x
)
.
poly
{
1
}
=
1
;
else
pmod
(
x
)
.
name
{
1
}
=
''
;
pmod
(
x
)
.
param
{
1
}
=
[];
pmod
(
x
)
.
poly
{
1
}
=
[];
end
end
save
(
sprintf
(
'onsets_emo_lightmod_Mel_6Con_noblocks_%s.mat'
,
entry_table
),
'onsets'
,
'durations'
,
'pmod'
,
'names'
);
end
cd
(
paths
.
data
)
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment