From: Steven on
Hi all,

I am stuck on a problem in one of my scripts.
In this script I am using the textscan function to read a .txt file into an array.

The code I am using is:

fid = fopen(strcat(OPENPATH, FILENAME));
Data = textscan(fid, '%d64 %*s %d32 %*f %*f %f %f %*f %*f %*f %*f', 'headerLines', 23, ...
'treatAsEmpty', {'MSG', TRIALSEPARATOR}, 'emptyValue', 0);
fclose(fid);

If I read the following .txt data into this array, everything works fine:
------------------------------------------------------------------------------
## [iView]
## Converted from: C:\Program Files\SMI\iView X\data\Steven\LaVie\TestingData\EyeTracker\107FR26ES1.idf
## Date: 28.01.2010 09:17
## Version: IDF Converter 2.01 build 21
## Sample Rate: 240
## [Trial]
## User:
## Trial:
## [Calibration]
## Calibration Type: 9-point with corner correction
## Calibration Area: 1280 1024
## [Geometry]
## Stimulus Dimension [mm]: 300 200
## Head Distance [mm]: 900
## [Hardware Setup]
## [Presentation]
## Number of Samples: -100
## Reversed: none
## Format: LEFT. RAW. DIAMETER. CR. POR
##
Time Type Set L Raw X [px] L Raw Y [px] L Dia X [px] L Dia Y [px] L CR1 X [px] L CR1 Y [px] L POR X [px] L POR Y [px]
17265383271 MSG Scene Image: C:\Program Files\SMI\iView X\CAL1280.BMP
0 SMP 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
29375 SMP 1 170.19 109.94 79 76 158.63 630.3 538.69 1
29376 SMP 1 170.18 109.92 79 74 158.64 630.25 538.39 1
29377 SMP 1 170.11 109.99 79 74 158.52 630.64 538.35 1
29378 SMP 1 169.26 110.11 79 76 158.05 622.87 541.67 1
29379 SMP 1 167.53 110.05 80 76 157.39 581.02 541.22 1
29380 SMP 1 165.63 109.68 79 74 156.71 537.78 522.85 1
29381 SMP 1 164.47 109.44 79 74 156.26 513.32 506.54 1
29382 SMP 1 164.16 109.55 79 74 155.99 512.54 508.55 1
29383 SMP 1 164.52 109.74 79 74 155.96 523.12 513.78 1
29384 SMP 1 164.77 109.87 79 74 156.05 528.25 516.28 1
29385 SMP 1 165.07 110.02 80 74 156.22 532.83 522.32 1
29386 SMP 1 165.24 110 80 74 156.32 535.55 521.63 1
etcetera.
--------------------------

However, when trying to read the following .txt file. Data ends up being an empty 1x4 array:
------------------
## [iView]
## Converted from: C:\Program Files\SMI\iView X\data\Steven\LaVie\TestingData\EyeTracker\114FL23ES2part1.idf
## Date: 27.01.2010 13:38
## Version: IDF Converter 2.01 build 21
## Sample Rate: 240
## [Trial]
## User:
## Trial:
## [Calibration]
## Calibration Type: 9-point with corner correction
## Calibration Area: 1280 1024
## [Geometry]
## Stimulus Dimension [mm]: 300 200
## Head Distance [mm]: 900
## [Hardware Setup]
## [Presentation]
## Number of Samples: -100
## Reversed: none
## Format: LEFT. RAW. DIAMETER. CR. POR
##
Time Type Set L Raw X [px] L Raw Y [px] L Dia X [px] L Dia Y [px] L CR1 X [px] L CR1 Y [px] L POR X [px] L POR Y [px]
4485531414 MSG Scene Image: C:\Program Files\SMI\iView X\CAL1280.BMP
0 SMP 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
32421 SMP 1 183.64 93.76 68 70 179.83 435.65 418.87 1
32422 SMP 1 182.98 93.76 69 70 179.72 414.05 418.02 1
32423 SMP 1 182.83 93.63 69 70 179.55 412.66 414.54 1
32424 SMP 1 182.9 93.62 69 70 179.37 420.16 412.58 1
32425 SMP 1 182.67 93.7 68 70 179.13 421.82 413.3 1
32426 SMP 1 182.34 93.78 69 70 178.8 423.19 417.71 1
32427 SMP 1 182.11 93.68 69 70 178.55 424.2 420.27 1
32428 SMP 1 181.92 93.52 68 69 178.42 423.65 420.36 1
32429 SMP 1 181.78 93.39 68 70 178.21 424.15 420.52 1
32430 SMP 1 181.65 93.23 68 70 177.96 426.57 420.41 1
32431 SMP 1 181.47 93.06 68 70 177.81 427.84 420.39 1
32432 SMP 1 181.31 92.86 69 70 177.63 428.88 420.53 1
etcetera
-----------------------------

Does anyone have an idea why this happens?

All help is highly appreciated,

cheers,
Steven
From: Steven on
Update after seeing how the message displays data:

note that the data as shown in the message is not exactly in the same format as the actual .txt files.

In both cases the 23rd line is:
0 SMP 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00


Steven


"Steven " <stevenvandepavert(a)gmail.com> wrote in message <i02p6m$rlh$1(a)fred.mathworks.com>...
> Hi all,
>
> I am stuck on a problem in one of my scripts.
> In this script I am using the textscan function to read a .txt file into an array.
>
> The code I am using is:
>
> fid = fopen(strcat(OPENPATH, FILENAME));
> Data = textscan(fid, '%d64 %*s %d32 %*f %*f %f %f %*f %*f %*f %*f', 'headerLines', 23, ...
> 'treatAsEmpty', {'MSG', TRIALSEPARATOR}, 'emptyValue', 0);
> fclose(fid);
>
> If I read the following .txt data into this array, everything works fine:
> ------------------------------------------------------------------------------
> ## [iView]
> ## Converted from: C:\Program Files\SMI\iView X\data\Steven\LaVie\TestingData\EyeTracker\107FR26ES1.idf
> ## Date: 28.01.2010 09:17
> ## Version: IDF Converter 2.01 build 21
> ## Sample Rate: 240
> ## [Trial]
> ## User:
> ## Trial:
> ## [Calibration]
> ## Calibration Type: 9-point with corner correction
> ## Calibration Area: 1280 1024
> ## [Geometry]
> ## Stimulus Dimension [mm]: 300 200
> ## Head Distance [mm]: 900
> ## [Hardware Setup]
> ## [Presentation]
> ## Number of Samples: -100
> ## Reversed: none
> ## Format: LEFT. RAW. DIAMETER. CR. POR
> ##
> Time Type Set L Raw X [px] L Raw Y [px] L Dia X [px] L Dia Y [px] L CR1 X [px] L CR1 Y [px] L POR X [px] L POR Y [px]
> 17265383271 MSG Scene Image: C:\Program Files\SMI\iView X\CAL1280.BMP
> 0 SMP 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
> 29375 SMP 1 170.19 109.94 79 76 158.63 630.3 538.69 1
> 29376 SMP 1 170.18 109.92 79 74 158.64 630.25 538.39 1
> 29377 SMP 1 170.11 109.99 79 74 158.52 630.64 538.35 1
> 29378 SMP 1 169.26 110.11 79 76 158.05 622.87 541.67 1
> 29379 SMP 1 167.53 110.05 80 76 157.39 581.02 541.22 1
> 29380 SMP 1 165.63 109.68 79 74 156.71 537.78 522.85 1
> 29381 SMP 1 164.47 109.44 79 74 156.26 513.32 506.54 1
> 29382 SMP 1 164.16 109.55 79 74 155.99 512.54 508.55 1
> 29383 SMP 1 164.52 109.74 79 74 155.96 523.12 513.78 1
> 29384 SMP 1 164.77 109.87 79 74 156.05 528.25 516.28 1
> 29385 SMP 1 165.07 110.02 80 74 156.22 532.83 522.32 1
> 29386 SMP 1 165.24 110 80 74 156.32 535.55 521.63 1
> etcetera.
> --------------------------
>
> However, when trying to read the following .txt file. Data ends up being an empty 1x4 array:
> ------------------
> ## [iView]
> ## Converted from: C:\Program Files\SMI\iView X\data\Steven\LaVie\TestingData\EyeTracker\114FL23ES2part1.idf
> ## Date: 27.01.2010 13:38
> ## Version: IDF Converter 2.01 build 21
> ## Sample Rate: 240
> ## [Trial]
> ## User:
> ## Trial:
> ## [Calibration]
> ## Calibration Type: 9-point with corner correction
> ## Calibration Area: 1280 1024
> ## [Geometry]
> ## Stimulus Dimension [mm]: 300 200
> ## Head Distance [mm]: 900
> ## [Hardware Setup]
> ## [Presentation]
> ## Number of Samples: -100
> ## Reversed: none
> ## Format: LEFT. RAW. DIAMETER. CR. POR
> ##
> Time Type Set L Raw X [px] L Raw Y [px] L Dia X [px] L Dia Y [px] L CR1 X [px] L CR1 Y [px] L POR X [px] L POR Y [px]
> 4485531414 MSG Scene Image: C:\Program Files\SMI\iView X\CAL1280.BMP
> 0 SMP 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
> 32421 SMP 1 183.64 93.76 68 70 179.83 435.65 418.87 1
> 32422 SMP 1 182.98 93.76 69 70 179.72 414.05 418.02 1
> 32423 SMP 1 182.83 93.63 69 70 179.55 412.66 414.54 1
> 32424 SMP 1 182.9 93.62 69 70 179.37 420.16 412.58 1
> 32425 SMP 1 182.67 93.7 68 70 179.13 421.82 413.3 1
> 32426 SMP 1 182.34 93.78 69 70 178.8 423.19 417.71 1
> 32427 SMP 1 182.11 93.68 69 70 178.55 424.2 420.27 1
> 32428 SMP 1 181.92 93.52 68 69 178.42 423.65 420.36 1
> 32429 SMP 1 181.78 93.39 68 70 178.21 424.15 420.52 1
> 32430 SMP 1 181.65 93.23 68 70 177.96 426.57 420.41 1
> 32431 SMP 1 181.47 93.06 68 70 177.81 427.84 420.39 1
> 32432 SMP 1 181.31 92.86 69 70 177.63 428.88 420.53 1
> etcetera
> -----------------------------
>
> Does anyone have an idea why this happens?
>
> All help is highly appreciated,
>
> cheers,
> Steven
From: us on
"Steven " <stevenvandepavert(a)gmail.com> wrote in message <i02p6m$rlh$1(a)fred.mathworks.com>...
> Hi all,
>
> I am stuck on a problem in one of my scripts.
> In this script I am using the textscan function to read a .txt file into an array.
>
> The code I am using is:
>
> fid = fopen(strcat(OPENPATH, FILENAME));
> Data = textscan(fid, '%d64 %*s %d32 %*f %*f %f %f %*f %*f %*f %*f', 'headerLines', 23, ...
> 'treatAsEmpty', {'MSG', TRIALSEPARATOR}, 'emptyValue', 0);
> fclose(fid);
>
> If I read the following .txt data into this array, everything works fine:
> ------------------------------------------------------------------------------
> ## [iView]
> ## Converted from: C:\Program Files\SMI\iView X\data\Steven\LaVie\TestingData\EyeTracker\107FR26ES1.idf
> ## Date: 28.01.2010 09:17
> ## Version: IDF Converter 2.01 build 21
> ## Sample Rate: 240
> ## [Trial]
> ## User:
> ## Trial:
> ## [Calibration]
> ## Calibration Type: 9-point with corner correction
> ## Calibration Area: 1280 1024
> ## [Geometry]
> ## Stimulus Dimension [mm]: 300 200
> ## Head Distance [mm]: 900
> ## [Hardware Setup]
> ## [Presentation]
> ## Number of Samples: -100
> ## Reversed: none
> ## Format: LEFT. RAW. DIAMETER. CR. POR
> ##
> Time Type Set L Raw X [px] L Raw Y [px] L Dia X [px] L Dia Y [px] L CR1 X [px] L CR1 Y [px] L POR X [px] L POR Y [px]
> 17265383271 MSG Scene Image: C:\Program Files\SMI\iView X\CAL1280.BMP
> 0 SMP 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
> 29375 SMP 1 170.19 109.94 79 76 158.63 630.3 538.69 1
> 29376 SMP 1 170.18 109.92 79 74 158.64 630.25 538.39 1
> 29377 SMP 1 170.11 109.99 79 74 158.52 630.64 538.35 1
> 29378 SMP 1 169.26 110.11 79 76 158.05 622.87 541.67 1
> 29379 SMP 1 167.53 110.05 80 76 157.39 581.02 541.22 1
> 29380 SMP 1 165.63 109.68 79 74 156.71 537.78 522.85 1
> 29381 SMP 1 164.47 109.44 79 74 156.26 513.32 506.54 1
> 29382 SMP 1 164.16 109.55 79 74 155.99 512.54 508.55 1
> 29383 SMP 1 164.52 109.74 79 74 155.96 523.12 513.78 1
> 29384 SMP 1 164.77 109.87 79 74 156.05 528.25 516.28 1
> 29385 SMP 1 165.07 110.02 80 74 156.22 532.83 522.32 1
> 29386 SMP 1 165.24 110 80 74 156.32 535.55 521.63 1
> etcetera.
> --------------------------
>
> However, when trying to read the following .txt file. Data ends up being an empty 1x4 array:
> ------------------
> ## [iView]
> ## Converted from: C:\Program Files\SMI\iView X\data\Steven\LaVie\TestingData\EyeTracker\114FL23ES2part1.idf
> ## Date: 27.01.2010 13:38
> ## Version: IDF Converter 2.01 build 21
> ## Sample Rate: 240
> ## [Trial]
> ## User:
> ## Trial:
> ## [Calibration]
> ## Calibration Type: 9-point with corner correction
> ## Calibration Area: 1280 1024
> ## [Geometry]
> ## Stimulus Dimension [mm]: 300 200
> ## Head Distance [mm]: 900
> ## [Hardware Setup]
> ## [Presentation]
> ## Number of Samples: -100
> ## Reversed: none
> ## Format: LEFT. RAW. DIAMETER. CR. POR
> ##
> Time Type Set L Raw X [px] L Raw Y [px] L Dia X [px] L Dia Y [px] L CR1 X [px] L CR1 Y [px] L POR X [px] L POR Y [px]
> 4485531414 MSG Scene Image: C:\Program Files\SMI\iView X\CAL1280.BMP
> 0 SMP 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
> 32421 SMP 1 183.64 93.76 68 70 179.83 435.65 418.87 1
> 32422 SMP 1 182.98 93.76 69 70 179.72 414.05 418.02 1
> 32423 SMP 1 182.83 93.63 69 70 179.55 412.66 414.54 1
> 32424 SMP 1 182.9 93.62 69 70 179.37 420.16 412.58 1
> 32425 SMP 1 182.67 93.7 68 70 179.13 421.82 413.3 1
> 32426 SMP 1 182.34 93.78 69 70 178.8 423.19 417.71 1
> 32427 SMP 1 182.11 93.68 69 70 178.55 424.2 420.27 1
> 32428 SMP 1 181.92 93.52 68 69 178.42 423.65 420.36 1
> 32429 SMP 1 181.78 93.39 68 70 178.21 424.15 420.52 1
> 32430 SMP 1 181.65 93.23 68 70 177.96 426.57 420.41 1
> 32431 SMP 1 181.47 93.06 68 70 177.81 427.84 420.39 1
> 32432 SMP 1 181.31 92.86 69 70 177.63 428.88 420.53 1
> etcetera
> -----------------------------
>
> Does anyone have an idea why this happens?
>
> All help is highly appreciated,
>
> cheers,
> Steven

ok... nice copy/paste...
but for those CSSMers, who don't have a lot of time:
can you just show the difference - please...

us
From: Steven on
"us " <us(a)neurol.unizh.ch> wrote in message
>
> ok... nice copy/paste...
> but for those CSSMers, who don't have a lot of time:
> can you just show the difference - please...
>
> us



That's exactly the point, I don't know what the difference is.
From: Steven on
Hi,

I simplified the question I am having, so someone hopefully can provide a solution.

The issue I am having with my textscan function is the following:

I am using this code:
------
fid = fopen(strcat('C:\test\', 'FILENAME.txt' ));
Data = textscan(fid, '%d64 %*s %d32 %*f %*f %f %f %*f %*f %*f %*f');
fclose(fid);
------

When using a txt file containing the following data, the variable Data ends up as it should:

29375 SMP 1 170.19 109.94 79 76 158.63 630.3 538.69 1

How3ver, when using this file, Data ends up as an 1x4 empty array:

15555 SMP 1 183.64 93.76 68 70 179.83 435.65 418.87 1

Hence my question, why? And how do I solve this?

thanks a lot in advance,
Steven