function [raw_values, peakz]=create_basic_text_file(file_to_read,electroaudio) %works on one raw (.hdf) file at a time; written initially for converting control experiments with okadaic acid to text (june 15 2005) %if electroaudio==1, patch traces only (columns 0 and 1 from dataset), if electroaudio==2, audio trace only (col 2 from dataset), if electroaudio==3, all three traces hdfml('closeall'),%clear all,close all,tic patchlog_name=strcat('/Users/tathagatagarbha/dwn_data_analysis_system/raw_data_dwn/', file_to_read,'.hdf'); save_that_sht=0; %open the patchlog created by update patchlog at the time of the recording converting_hdf=hdfsd('start',patchlog_name,'read'); [datasets_for_converted,nglobal_atts,stat_readinghdf]=hdfsd('fileinfo',converting_hdf); number_of_trials=datasets_for_converted converter_sds_id=hdfsd('select',converting_hdf,0); %take the first dataset in the .hdf file [ds_name, ds_ndims, ds_dims, ds_type, ds_atts, stat]=hdfsd('getinfo',converter_sds_id); %get info on the dataset stat_dataset_end_post=hdfsd('endaccess',converter_sds_id); windowing=0 returnrange=[-1000:30000]; raw_values=[]; %intervals=[]; stepz=[]; %for holding voltage steps peakz=[]; %number_of_trials=1 for trial=1:number_of_trials %choose the dataset for this trial converter_sds_id=hdfsd('select',converting_hdf,(trial-1)); %trial, corrected for zeroth indexing, tells which data set to read [ds_name, ds_ndims, ds_dims, ds_type, ds_atts, stat]=hdfsd('getinfo',converter_sds_id); samples_per_trigger=ds_dims(2) %get the ITI which preceded the current trial, which was stored as the ds_name by update_patchlog tri=trial measured_ITI=str2num(ds_name) ds_stride=[]; %these lines tell how the dataset should be read ds_edges=[1, samples_per_trigger]; if any(electroaudio==[1 3]) %read in the recording from the presynaptic neuron ds_start=[0 0]; %starts reading from the first row in the first column, with the row and column switched ala .hdf's indexing system [ds_dataein,status]=hdfsd('readdata',converter_sds_id,ds_start,ds_stride,ds_edges); %read in the recording from the postsynaptic neuron ds_start=[1 0]; %starts reading from the first row in the second column [ds_datazwei,status]=hdfsd('readdata',converter_sds_id,ds_start,ds_stride,ds_edges); %stepz=[stepz,ds_dataein(2)]; %if trial==1, ds_dataein=ds_dataein*10;end %balky=ds_dataein(1:9) ein=ds_dataein(10:end);%-mean(ds_dataein(10:2000)); ein_peaks=find_peaks_within_threshold_crossing_regions(4.95,50,ein) peakz=[peakz;ein_peaks]; zwei=ds_datazwei(10:end);%-mean(ds_datazwei(10:2000)); zwei_peaks=find_peaks_within_threshold_crossing_regions(1,50,zwei) %if zwei_peaks,zweimax=zwei(zwei_peaks(1));else zweimax=0;end %if einmax>zweimax, maxind=ein_peaks(1); elseif zweimax>einmax, maxind=zwei_peaks(1); else error('which trace has stim artifact?'), end if find(zwei_peaks),maxind=zwei_peaks(1); elseif any(find(ein_peaks)),maxind=ein_peaks(1), else maxind=abs(returnrange(1))+1;end %if length(ein)>size(raw_values,2), raw_values=[raw_values;zeros(length(ein)-size(raw_values,2)-1, size(raw_values,1))]; end%padding the end for stim_phil6 trials %target_length=100000; %if length(ein)