diff --git a/scripts/bb_register_blipdown_init.dat b/scripts/bb_register_blipdown_init.dat new file mode 100644 index 0000000..aeb6522 --- /dev/null +++ b/scripts/bb_register_blipdown_init.dat @@ -0,0 +1,9 @@ +011624 +5 +5 +0.250000 + 0.1286 0.9913 0.0271 10.7043 + -0.0360 -0.0226 0.9991 -10.4805 + 0.9910 -0.1296 0.0329 -0.7073 + 0 0 0 1.0000 +round diff --git a/scripts/bb_register_blipup_init.dat b/scripts/bb_register_blipup_init.dat new file mode 100644 index 0000000..506eb8e --- /dev/null +++ b/scripts/bb_register_blipup_init.dat @@ -0,0 +1,9 @@ +011624 +5 +5 +0.250000 + -0.0308 -0.9992 0.0248 -0.8783 + -0.0322 0.0259 0.9991 -10.8010 + 0.9990 -0.0301 0.0331 1.5833 + 0 0 0 1.0000 +round diff --git a/scripts/register_init_epi_blipdown.m b/scripts/register_init_epi_blipdown.m new file mode 100644 index 0000000..6a3d766 --- /dev/null +++ b/scripts/register_init_epi_blipdown.m @@ -0,0 +1,40 @@ +close all; clear all; + +subject='011624'; +hemi='rh'; +surf='white'; + + +file_overlay_register='./bb_register_blipdown_init.dat'; +%file_overlay_vol='epi__epi_blipdown.mgh'; +file_overlay_vol='epi__epi_blipdown_fliplr.mgh'; %use this one because SMS-InI has flipped A-P direction compared to EPI. +overlay_threshold=[]; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +setenv('SUBJECTS_DIR','/Users/fhlin/workspace/smsini_blipud/subjects/'); %for MAC/Linux +%setenv('SUBJECTS_DIR','D:\fhlin\Users\fhlin\workspace\seeg\subjects'); %for PC + +mri=MRIread(sprintf('/Users/fhlin/workspace/smsini_blipud/subjects/%s/mri/orig.mgz',subject)); %for MAC/Linux +%mri=etc_MRIread('D:\fhlin\Users\fhlin\workspace\seeg\subjects\2036\mri\orig.mgz'); %for PC + +%load the Talairach transformation matrix from the "pre-OP" data +talxfm=etc_read_xfm('file_xfm',sprintf('%s/%s/mri/transforms/talairach.xfm',getenv('SUBJECTS_DIR'),subject)); %for MAC/Linux +%talxfm=etc_read_xfm('file_xfm','D:\fhlin\Users\fhlin\workspace\seeg\subjects\2036\mri\transforms\talairach.xfm'); %for PC + +%%% volume overlay +f=MRIread(file_overlay_vol); + +r=etc_read_xfm('file_xfm',file_overlay_register); + +%prepare overlay volume matched to the underlay volume +vol = etc_MRIvol2vol(f,mri,r,'frames',[1]); %only the first volume + +%prepare overlay surface +vol2surf = etc_MRIvol2surf(f,surf,r,'subject',subject,'frames',[1],'hemi',hemi); + +%etc_render_fsbrain('surf',surf,'hemi',hemi,'subject',subject,'vol',mri,'talxfm',(talxfm),'overlay_vol',vol,'overlay_value',vol2surf,'overlay_vertex',[1:size(vol2surf,1)]-1,'overlay_threshold',overlay_threshold,'overlay_flag_paint_on_cortex',0); +etc_render_fsbrain('surf',surf,'hemi',hemi,'subject',subject,'vol',mri,'talxfm',(talxfm),'overlay_vol',vol,'overlay_threshold',overlay_threshold,'overlay_flag_paint_on_cortex',0); + +%1. calcualte r * overlay_xfm after exporting the registration in Matlab work space +% +%2. check initial registration at command line: tkregisterfv --mov smsini_mb_run_1_ref.mgh --reg bb_register_init.dat --surfs --sd /Users/fhlin/workspace/smsini_blipud/subjects/ diff --git a/scripts/register_init_epi_blipup.m b/scripts/register_init_epi_blipup.m new file mode 100644 index 0000000..36e206a --- /dev/null +++ b/scripts/register_init_epi_blipup.m @@ -0,0 +1,39 @@ +close all; clear all; + +subject='011624'; +hemi='rh'; +surf='white'; + + +file_overlay_register='./bb_register_blipup_init.dat'; +file_overlay_vol='epi__epi_blipup.mgh'; +overlay_threshold=[]; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +setenv('SUBJECTS_DIR','/Users/fhlin/workspace/smsini_blipud/subjects/'); %for MAC/Linux +%setenv('SUBJECTS_DIR','D:\fhlin\Users\fhlin\workspace\seeg\subjects'); %for PC + +mri=MRIread(sprintf('/Users/fhlin/workspace/smsini_blipud/subjects/%s/mri/orig.mgz',subject)); %for MAC/Linux +%mri=etc_MRIread('D:\fhlin\Users\fhlin\workspace\seeg\subjects\2036\mri\orig.mgz'); %for PC + +%load the Talairach transformation matrix from the "pre-OP" data +talxfm=etc_read_xfm('file_xfm',sprintf('%s/%s/mri/transforms/talairach.xfm',getenv('SUBJECTS_DIR'),subject)); %for MAC/Linux +%talxfm=etc_read_xfm('file_xfm','D:\fhlin\Users\fhlin\workspace\seeg\subjects\2036\mri\transforms\talairach.xfm'); %for PC + +%%% volume overlay +f=MRIread(file_overlay_vol); + +r=etc_read_xfm('file_xfm',file_overlay_register); + +%prepare overlay volume matched to the underlay volume +vol = etc_MRIvol2vol(f,mri,r,'frames',[1]); %only the first volume + +%prepare overlay surface +vol2surf = etc_MRIvol2surf(f,surf,r,'subject',subject,'frames',[1],'hemi',hemi); + +%etc_render_fsbrain('surf',surf,'hemi',hemi,'subject',subject,'vol',mri,'talxfm',(talxfm),'overlay_vol',vol,'overlay_value',vol2surf,'overlay_vertex',[1:size(vol2surf,1)]-1,'overlay_threshold',overlay_threshold,'overlay_flag_paint_on_cortex',0); +etc_render_fsbrain('surf',surf,'hemi',hemi,'subject',subject,'vol',mri,'talxfm',(talxfm),'overlay_vol',vol,'overlay_threshold',overlay_threshold,'overlay_flag_paint_on_cortex',0); + +%1. calcualte r * overlay_xfm after exporting the registration in Matlab work space +% +%2. check initial registration at command line: tkregisterfv --mov smsini_mb_run_1_ref.mgh --reg bb_register_init.dat --surfs --sd /Users/fhlin/workspace/smsini_blipud/subjects/ diff --git a/scripts/smsini_tsnr.m b/scripts/smsini_tsnr.m new file mode 100644 index 0000000..bfbd617 --- /dev/null +++ b/scripts/smsini_tsnr.m @@ -0,0 +1,65 @@ +close all; clear all; + +stc_file_stem={ + 'smsini_mb_run_1_acc'; + 'smsini_mb_run_2_acc'; + }; + +for file_idx=1:length(stc_file_stem) + for hemi=1:2 + switch hemi + case 1 + hemi_str='lh'; + case 2 + hemi_str='rh'; + end; + + fn=sprintf('%s-%s.stc',stc_file_stem{file_idx},hemi_str); + [stc,v{hemi}]=inverse_read_stc(fn); + + + [tsnr{file_idx,hemi}]=etc_tsnr('stc',stc,'exclude_time',[1:10]); + + fn_out=sprintf('%s_tsnr-%s.stc',stc_file_stem{file_idx},hemi_str); + + inverse_write_stc(repmat(tsnr{file_idx,hemi}(:),[1 5]),v{hemi},0,100,fn_out); + end; + + for hemi=1:2 + switch hemi + case 1 + hemi_str='lh'; + case 2 + hemi_str='rh'; + end; + + etc_render_fsbrain('subject','011624','overlay_vertex',v{hemi},'overlay_value',tsnr{file_idx,hemi}(:),'overlay_threshold',[50 500]); + + + %generate image outputs + for view_idx=1:2 + switch(hemi_str) + case 'lh' + if(view_idx==1) + view(90,0); + view_str='med'; + elseif(view_idx==2) + view(-90,0); + view_str='lat'; + end; + case 'rh' + if(view_idx==1) + view(-90,0); + view_str='med'; + elseif(view_idx==2) + view(90,0); + view_str='lat'; + end; + end; + hgexport(gcf,sprintf('%s_%s_%s.png',stc_file_stem{file_idx},hemi_str,view_str), hgexport('factorystyle'),'Format','png'); + end; + close; + end; +end; + +save smsini_tsnr.mat tsnr; \ No newline at end of file