Пример #1
0
int KWEFile::createFileStructure()
{
    const uint16 ver = 2;
    if (createGroup("/recordings")) return -1;
    if (createGroup("/event_types")) return -1;
    for (int i=0; i < eventNames.size(); i++)
    {
        ScopedPointer<HDF5RecordingData> dSet;
        String path = "/event_types/" + eventNames[i];
        if (createGroup(path)) return -1;
        path += "/events";
        if (createGroup(path)) return -1;
        dSet = createDataSet(U64,0,EVENT_CHUNK_SIZE,path + "/time_samples");
        if (!dSet) return -1;
        dSet = createDataSet(U16,0,EVENT_CHUNK_SIZE,path + "/recording");
        if (!dSet) return -1;
        path += "/user_data";
        if (createGroup(path)) return -1;
        dSet = createDataSet(U8,0,EVENT_CHUNK_SIZE,path + "/eventID");
        if (!dSet) return -1;
        dSet = createDataSet(U8,0,EVENT_CHUNK_SIZE,path + "/nodeID");
        if (!dSet) return -1;
        dSet = createDataSet(eventTypes[i],0,EVENT_CHUNK_SIZE,path + "/" + eventDataNames[i]);
        if (!dSet) return -1;
    }
    if (setAttribute(U16,(void*)&ver,"/","kwik_version")) return -1;
    return 0;
}
Пример #2
0
int KWXFile::createChannelGroup(int index)
{
    ScopedPointer<HDF5RecordingData> dSet;
    int nChannels = channelArray[index];
    String path("/channel_groups/"+String(index));
    CHECK_ERROR(createGroup(path));
    dSet = createDataSet(I16,0,0,nChannels,SPIKE_CHUNK_XSIZE,SPIKE_CHUNK_YSIZE,path+"/waveforms_filtered");
    if (!dSet) return -1;
    dSet = createDataSet(U64,0,SPIKE_CHUNK_XSIZE,path+"/time_samples");
    if (!dSet) return -1;
    dSet = createDataSet(U16,0,SPIKE_CHUNK_XSIZE,path+"/recordings");
    if (!dSet) return -1;
    return 0;
}
Пример #3
0
/*!
 * \brief This method creates a MockDataSourceTransactor
 * \return Returns a mocked DataSourceTransactor that has the required behavior for unittests
 */
te::da::MockDataSourceTransactor* createMockDataSourceTransactor()
{
  te::da::MockDataSourceTransactor* mockDataSourceTransactor(new te::da::MockDataSourceTransactor());

  EXPECT_CALL(*mockDataSourceTransactor, createDataSet(::testing::_, ::testing::_)).WillRepeatedly(::testing::Return());
  EXPECT_CALL(*mockDataSourceTransactor, PrimaryKeyPtrReturn()).WillRepeatedly(::testing::Return(new te::da::PrimaryKey()));
  EXPECT_CALL(*mockDataSourceTransactor, execute(::testing::An<const std::string&>())).WillRepeatedly(::testing::Return());
  EXPECT_CALL(*mockDataSourceTransactor, commit()).WillRepeatedly(::testing::Return());
  EXPECT_CALL(*mockDataSourceTransactor, getLastGeneratedId()).WillRepeatedly(::testing::Return(1));
  EXPECT_CALL(*mockDataSourceTransactor, PropertyPtrReturn()).WillRepeatedly(::testing::Return(nullptr));
  EXPECT_CALL(*mockDataSourceTransactor, addPrimaryKey(::testing::An<const std::string&>(), ::testing::_)).WillRepeatedly(::testing::Return());
  EXPECT_CALL(*mockDataSourceTransactor, addForeignKey(::testing::An<const std::string&>(), ::testing::_)).WillRepeatedly(::testing::Return());
  EXPECT_CALL(*mockDataSourceTransactor, escape(::testing::An<const std::string&>())).WillRepeatedly(::testing::Return(""));
  EXPECT_CALL(*mockDataSourceTransactor, isInTransaction()).WillRepeatedly(::testing::Return(false));
  EXPECT_CALL(*mockDataSourceTransactor, begin()).WillRepeatedly(::testing::Return());


  /* Every time the mockDataSourceTransactor object calls a method that returns a DataSet
   * the actualy method called will be the createMockDataSet() that returns a
   * new mocked DataSet.
   * A new mocked object is needed in every call because TerraLib takes ownership from the pointer.
   */
  EXPECT_CALL(*mockDataSourceTransactor, DataSetPtrReturn()).WillRepeatedly(::testing::Invoke(&createMockDataSet));

  return mockDataSourceTransactor;
}
Пример #4
0
void KWDFile::startNewRecording(int recordingNumber, int nChannels, KWIKRecordingInfo* info)
{
    this->recordingNumber = recordingNumber;
    this->nChannels = nChannels;
    this->multiSample = info->multiSample;
    uint8 mSample = info->multiSample ? 1 : 0;

	ScopedPointer<HDF5RecordingData> bitVoltsSet;
	ScopedPointer<HDF5RecordingData> sampleRateSet;

    String recordPath = String("/recordings/")+String(recordingNumber);
    CHECK_ERROR(createGroup(recordPath));
    CHECK_ERROR(setAttributeStr(info->name,recordPath,String("name")));
    CHECK_ERROR(setAttribute(U64,&(info->start_time),recordPath,String("start_time")));
    CHECK_ERROR(setAttribute(U32,&(info->start_sample),recordPath,String("start_sample")));
    CHECK_ERROR(setAttribute(F32,&(info->sample_rate),recordPath,String("sample_rate")));
    CHECK_ERROR(setAttribute(U32,&(info->bit_depth),recordPath,String("bit_depth")));
    CHECK_ERROR(createGroup(recordPath+"/application_data"));
   // CHECK_ERROR(setAttributeArray(F32,info->bitVolts.getRawDataPointer(),info->bitVolts.size(),recordPath+"/application_data",String("channel_bit_volts")));
	bitVoltsSet = createDataSet(F32, info->bitVolts.size(), 0, recordPath + "/application_data/channel_bit_volts");
	if (bitVoltsSet.get())
		bitVoltsSet->writeDataBlock(info->bitVolts.size(), F32, info->bitVolts.getRawDataPointer());
	else
		std::cerr << "Error creating bitvolts data set" << std::endl;
	
    CHECK_ERROR(setAttribute(U8,&mSample,recordPath+"/application_data",String("is_multiSampleRate_data")));
    //CHECK_ERROR(setAttributeArray(F32,info->channelSampleRates.getRawDataPointer(),info->channelSampleRates.size(),recordPath+"/application_data",String("channel_sample_rates")));
	sampleRateSet = createDataSet(F32, info->channelSampleRates.size(), 0, recordPath + "/application_data/channel_sample_rates");
	if (sampleRateSet.get())
		sampleRateSet->writeDataBlock(info->channelSampleRates.size(), F32, info->channelSampleRates.getRawDataPointer());
	else
		std::cerr << "Error creating sample rates data set" << std::endl;

    recdata = createDataSet(I16,0,nChannels,CHUNK_XSIZE,recordPath+"/data");
    if (!recdata.get())
        std::cerr << "Error creating data set" << std::endl;

	tsData = createDataSet(I64, 0, nChannels, TIMESTAMP_CHUNK_SIZE, recordPath + "/application_data/timestamps");
	if (!tsData.get())
		std::cerr << "Error creating timestamps data set" << std::endl;

    curChan = nChannels;
}
Пример #5
0
void wrapper_createdataset(char **R_input_file, int *R_seed, double *R_percentage,
                     char **R_output_file)
{
        // for random in R
        GetRNGstate();

        createDataSet(*R_input_file, (long long)(*R_seed), *R_percentage,
                      *R_output_file);

        // for random in R
        PutRNGstate();
}
Пример #6
0
//--------------------------------------------------------------------------
// Function:	CommonFG::createDataSet
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c H5std_string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
DataSet CommonFG::createDataSet( const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist ) const
{
   return( createDataSet( name.c_str(), data_type, data_space, create_plist ));
}