function [raw_values,peakz,pulse_duration_presyn,sampling_rate]=create_basic_text_file_justforrealtime(file_to_read,number_of_trials)
%description: opens one raw (.hdf) file and reads the contents
%called by: retrieve_extracted_data
%calls:
%notes:
%code confirmed date: 

hdfml('closeall');

if ismac, paththismachine='/Users/tathagatagarbha/dwn_data_analysis_system/'; elseif isunix, paththismachine='/home/dwn/Desktop/dwn_produ/'; end

%patchlog_name=strcat('H:\work_modulebayHD\', file_to_read,'.hdf');
%patchlog_name=strcat('F:\DriveH\work_modulebayHD\', file_to_read,'.hdf');
%patchlog_name=strcat('C:\Users\Idea\Desktop\dwn\DriveH\work_modulebayHD\', file_to_read,'.hdf');
patchlog_name=strcat(paththismachine,'raw_data_dwn/',file_to_read,'.hdf');

%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);

raw_values=[];peakz=[];
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
    measured_ITI=str2num(ds_name);
    ds_stride=[];       %these lines tell how the dataset should be read
    ds_edges=[1, samples_per_trigger];
    %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 the .hdf 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); 
    stat=hdfsd('endaccess',converter_sds_id);  %closing the data set after having read it
    
    pulse_duration_presyn=ds_dataein(3);
    sampling_rate=ds_dataein(5);
    ein=ds_dataein(10:end);%-mean(ds_dataein(10:2000));
    ein_peaks=find_peaks_within_threshold_crossing_regions(.5,100,ein);
    peakz=[peakz;ein_peaks];
    zwei=ds_datazwei(10:end);%-mean(ds_datazwei(10:2000));
    raw_values=[raw_values ein zwei];
	%intervals=[intervals ein_peaks(end)-ein_peaks(end-1)];
end
if length(peakz)~=60, error('not enough peaks detected'),end

%closing the patchlog file
stat_hdfend=hdfsd('end',converting_hdf);