Results 1 to 4 of 4

Thread: Saving two data sets to the same file

  1. #1
    Join Date
    Aug 2016
    Posts
    3
    Qt products
    Qt3 Qt5
    Platforms
    Windows

    Default Saving two data sets to the same file

    Hello,
    I'm working on an open source code for the Intan RDH2000 interface software.
    I have two types of signals data - amplifier and auxiliary.
    The amplifier is saved in the qint16 format and the auxiliary in the uqint16 format.
    Moreover, the amplifier data is sampled every at each time step while the auxiliary data is sampled only at each 4th time step.
    I'm trying (and so far failing) to merge these two signals type so they will both be on the same file with the same qint16 format.
    About the time step, I don't mind to duplicate the auxiliary data so it will be identical for each 4 consecutive time steps.

    Here is the function I'm working on, I'm new to QT and a little rusty in C++ so I would appreciate any suggestion you might have:
    Qt Code:
    1. // Save amplifier data
    2. bufferIndex = 0;
    3. for (t = 0; t < SAMPLES_PER_DATA_BLOCK; ++t) {
    4. for (i = 0; i < saveListAmplifier.size(); ++i) {
    5. tempQint16 = (qint16)
    6. (dataQueue.front().amplifierData[saveListAmplifier.at(i)->boardStream][saveListAmplifier.at(i)->chipChannel][t] - 32768);
    7. dataStreamBuffer[bufferIndex++] = tempQint16 & 0x00ff; // Save qint16 in little-endian format (LSByte first)
    8. dataStreamBuffer[bufferIndex++] = (tempQint16 & 0xff00) >> 8; // (MSByte last)
    9. }
    10. }
    11. if (bufferIndex > 0) {
    12. amplifierStream->writeRawData(dataStreamBuffer, bufferIndex); // Stream out all data at once to speed writing
    13. numWordsWritten += saveListAmplifier.size() * SAMPLES_PER_DATA_BLOCK;
    14. }
    15.  
    16. // Save auxiliary input data
    17. bufferIndex = 0;
    18. for (t = 0; t < SAMPLES_PER_DATA_BLOCK; ++t) {
    19. tAux = 4 * qFloor((double) t / 4.0);
    20. for (i = 0; i < saveListAuxInput.size(); ++i) {
    21. tempQuint16 = (quint16)
    22. dataQueue.front().auxiliaryData[saveListAuxInput.at(i)->boardStream][1][tAux + saveListAuxInput.at(i)->chipChannel + 1];
    23. dataStreamBuffer[bufferIndex++] = tempQuint16 & 0x00ff; // Save quint16 in little-endian format (LSByte first)
    24. dataStreamBuffer[bufferIndex++] = (tempQuint16 & 0xff00) >> 8; // (MSByte last)
    25. }
    26. }
    27. if (bufferIndex > 0) {
    28. auxInputStream->writeRawData(dataStreamBuffer, bufferIndex); // Stream out all data at once to speed writing
    29. numWordsWritten += saveListAuxInput.size() * SAMPLES_PER_DATA_BLOCK;
    30. }
    To copy to clipboard, switch view to plain text mode 

    With thanks,
    Amir
    Last edited by anda_skoa; 31st August 2016 at 09:26. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Saving two data sets to the same file

    When you say you are failing, what is happening and what are you expecting happen instead?

    Cheers,
    _

  3. #3
    Join Date
    Aug 2016
    Posts
    3
    Qt products
    Qt3 Qt5
    Platforms
    Windows

    Default Re: Saving two data sets to the same file

    I want the resulting file to be in the format of:
    Amp1(t1) Amp2(t1) Amp3(t1).... Amp32(t1) Aux1(t1) Aux2(t1) ... Aux8(t1) Amp1(t2) Amp2(t2) .... Amp32(t2) Aux1(t2) Aux2(t2) ... Aux8(t2) and so on.
    So far I'm not sure What I'm getting but it's not that.
    I want to use the the "information preserving" option (uint16 to int16): translate (shift) to the -2^15 to 2^15-1 range which changes the values but preserve the data.

    Best wishes,
    Amir

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Saving two data sets to the same file

    if you want this to be grouped by time, then you need to put the amp loop and the aux loop into the same time loop.

    Currently you are iterating over your time range, then first write all amp values, then repeat the whole thing for aux.

    I.e. you get

    Amp1(t1), Amp2(t1), ..., Amp32(tMax), Aux1(t1), Aux2(t1), ..., Aux8(tMax)

    Cheers,
    _

Similar Threads

  1. QTableView and Large data sets
    By KenJustKen in forum Qt Programming
    Replies: 3
    Last Post: 25th January 2016, 09:16
  2. Replies: 5
    Last Post: 2nd July 2012, 20:49
  3. Replies: 1
    Last Post: 22nd September 2010, 15:39
  4. Saving pure plot data to image file
    By Debilski in forum Qwt
    Replies: 4
    Last Post: 7th April 2009, 17:02
  5. Creating images from sets of data.
    By maverick_pol in forum Qt Programming
    Replies: 5
    Last Post: 26th February 2008, 09:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.