%   getconvecfmri

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION. 


%pulsevec=5+[1,  4,  7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 115, 118, 121, 124, 127, 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, 160, 163, 166, 169, 172, 175, 178, 181, 184, 187, 190, 193, 196, 199, 202, 205, 208, 211, 214, 217, 220, 223, 226, 229, 232, 235, 238, 241, 244, 247];
pulsevec=4+[1,  4,  7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 115, 118, 121, 124, 127, 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, 160, 163, 166, 169, 172, 175, 178, 181, 184, 187, 190, 193, 196, 199, 202, 205, 208, 211, 214, 217, 220, 223, 226, 229, 232, 235, 238, 241, 244, 247];
convec = [3,3,1,2,3,1,1,3,3,3,2,1,2,2,2,1,2,1,3,1,1,2,3,1,1,3,3,1,3,3,3,2,2,2,1,3,2,3,3,2,2,2,3,2,3,1,3,3,2,2,1,2,3,1,2,2,3,3,1,3,1,2,1,1,2,1,1,3,2,3,2,1,1,1,3,2,1,2,1,1,3,1,2];

neutpulses = pulsevec(find(convec==3));
%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.                                                                      
pospulses = pulsevec(find(convec==1));
negpulses = pulsevec(find(convec==2));

xjitterpos=[3,2,4,2,2,3,4,4,2,4,4,1,1,1,2,1,3,1,3,3,2,2,3,1,4,3,1,4]./4;
xjitterneg=[2,4,1,1,3,4,2,2,3,1,3,1,1,1,4,3,2,4,2,3,3,2,2,4,1,4,3]./4;
xjitterneu=[1,3,1,4,2,4,1,2,4,1,2,2,4,4,1,3,2,3,2,2,1,1,4,3,3,3,3,4]./4;

neutpulses = neutpulses + xjitterneu
pospulses = pospulses + xjitterpos
negpulses = negpulses + xjitterneg
path = uigetdir
cd(path);
pfid = fopen('pos.txt','wt');
nfid = fopen('neg.txt','wt');
ntfid = fopen('neut.txt','wt');

fprintf(pfid ,num2str(pospulses));
fprintf(nfid ,num2str(negpulses));
fprintf(ntfid ,num2str(neutpulses));
fclose(pfid);
fclose(nfid);
fclose(ntfid);