Skip to main content
Re-uploaded example file
Source Link
Aart Goossens
  • 1.6k
  • 12
  • 21

From an experiment, I have a dataset of beat-to-beat heart rate data: a list of the time between each heart beat in [ms]. The data is measured using an infrared optic sensor at the finger tip. The sensor frequently misinterprets a slight movement of the finger as an heart beat. Data therefore often looks somewhat like this:

{1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 600, 400, 1000}

In this example, one can easily see that the 5th and 6th element should be one; same for the 10th and 11th. However, in real life the data looks more like this:

data = {981, 870, 1099, 1105, 650, 397, 920, 917, 1015, 1085, 210, 344, 457,
950}

where the 5-6 (650, 397) and 11-12-13 (210, 344, 457) should be taken together. It is easy to just delete the incorrect data by using something like:

DeleteCases[data,
x_ /; x < Mean[data] - StandardDeviation[data] || 
x > Mean[data] + StandardDeviation[data]]

...but I want to make a function that recognizes when multiple elements should be added to one.

One could just add every two, three or four (=length) elements and select the Cases where the result lies (for example) in the range Mean[data]±StandardDeviation[data]:

length = 2;
Position[Total[data[[# ;; # + length]]] & /@ 
  Range[Length[data] - length], 
 x_ /; x > Mean[data] - StandardDeviation[data] && 
   x < Mean[data] + StandardDeviation[data]]

Result:

{{5}, {11}, {12}}

This gives me an idea of where the incorrect data is. Unfortunately, after having this result, I don't know what to do with it... For example, I get confused by the fact that elements 11-12-13 return 2 cases of incorrect data when I use length=1. And maybe there are more (simple) ways to filter this data.

Question: can anyone give me a kick-start?

Edit: You can download an example of actual data herehere. Just Flatten[Import[filename,"Table"]]

From an experiment, I have a dataset of beat-to-beat heart rate data: a list of the time between each heart beat in [ms]. The data is measured using an infrared optic sensor at the finger tip. The sensor frequently misinterprets a slight movement of the finger as an heart beat. Data therefore often looks somewhat like this:

{1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 600, 400, 1000}

In this example, one can easily see that the 5th and 6th element should be one; same for the 10th and 11th. However, in real life the data looks more like this:

data = {981, 870, 1099, 1105, 650, 397, 920, 917, 1015, 1085, 210, 344, 457,
950}

where the 5-6 (650, 397) and 11-12-13 (210, 344, 457) should be taken together. It is easy to just delete the incorrect data by using something like:

DeleteCases[data,
x_ /; x < Mean[data] - StandardDeviation[data] || 
x > Mean[data] + StandardDeviation[data]]

...but I want to make a function that recognizes when multiple elements should be added to one.

One could just add every two, three or four (=length) elements and select the Cases where the result lies (for example) in the range Mean[data]±StandardDeviation[data]:

length = 2;
Position[Total[data[[# ;; # + length]]] & /@ 
  Range[Length[data] - length], 
 x_ /; x > Mean[data] - StandardDeviation[data] && 
   x < Mean[data] + StandardDeviation[data]]

Result:

{{5}, {11}, {12}}

This gives me an idea of where the incorrect data is. Unfortunately, after having this result, I don't know what to do with it... For example, I get confused by the fact that elements 11-12-13 return 2 cases of incorrect data when I use length=1. And maybe there are more (simple) ways to filter this data.

Question: can anyone give me a kick-start?

Edit: You can download an example of actual data here. Just Flatten[Import[filename,"Table"]]

From an experiment, I have a dataset of beat-to-beat heart rate data: a list of the time between each heart beat in [ms]. The data is measured using an infrared optic sensor at the finger tip. The sensor frequently misinterprets a slight movement of the finger as an heart beat. Data therefore often looks somewhat like this:

{1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 600, 400, 1000}

In this example, one can easily see that the 5th and 6th element should be one; same for the 10th and 11th. However, in real life the data looks more like this:

data = {981, 870, 1099, 1105, 650, 397, 920, 917, 1015, 1085, 210, 344, 457,
950}

where the 5-6 (650, 397) and 11-12-13 (210, 344, 457) should be taken together. It is easy to just delete the incorrect data by using something like:

DeleteCases[data,
x_ /; x < Mean[data] - StandardDeviation[data] || 
x > Mean[data] + StandardDeviation[data]]

...but I want to make a function that recognizes when multiple elements should be added to one.

One could just add every two, three or four (=length) elements and select the Cases where the result lies (for example) in the range Mean[data]±StandardDeviation[data]:

length = 2;
Position[Total[data[[# ;; # + length]]] & /@ 
  Range[Length[data] - length], 
 x_ /; x > Mean[data] - StandardDeviation[data] && 
   x < Mean[data] + StandardDeviation[data]]

Result:

{{5}, {11}, {12}}

This gives me an idea of where the incorrect data is. Unfortunately, after having this result, I don't know what to do with it... For example, I get confused by the fact that elements 11-12-13 return 2 cases of incorrect data when I use length=1. And maybe there are more (simple) ways to filter this data.

Question: can anyone give me a kick-start?

Edit: You can download an example of actual data here. Just Flatten[Import[filename,"Table"]]

edited tags
Link
added 13 characters in body; edited tags
Source Link

From an experiment i, I have a dataset of beat-to-beat heart rate data: a list of the time between each heart beat in [ms]. The data is measured using an infrared optic sensor at the finger tip. The sensor frequently misinterprets a slight movement of the finger as an heart beat. Data therefore often looks somewhat like this:

{1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 600, 400, 1000}

In this exapleexample, one can easily see that the 5th and 6th element should be one,one; same for the 10th and 11th. However, in real life the data looks more like this:

data=data = {981, 870, 1099, 1105, 650, 397, 920, 917, 1015, 1085, 210, 344, 457,
950}

Wherewhere the 5-6 (650, 397) and 11-12-13 (210, 344, 457) should be taken together. It is easy to just delete the incorrect data by using sometingsomething like:

DeleteCases[data,
x_ /; x < Mean[data] - StandardDeviation[data] || 
x > Mean[data] + StandardDeviation[data]]

...but iI want to make a function that recognizes when multiple elements should be added to one.

One could just add every two, three or four (=length=length) elements and select the CasesCases where the result lies (for example) in the range Mean[data]-/+StandardDeviation[data]Mean[data]±StandardDeviation[data]:

length = 2;
Position[Total[data[[# ;; # + length]]] & /@ 
  Range[Length[data] - length], 
 x_ /; x > Mean[data] - StandardDeviation[data] && 
   x < Mean[data] + StandardDeviation[data]]

Result:

{{5}, {11}, {12}}

This gives me an idea of where the incorrect data is. Unfortunately, after having this result, iI don't know what to do with it... For example, iI get confused by the fact that elements 11-12-13 return 2 cases of incorrect data when iI use length=1length=1. And maybe there are more (simple) ways to filter this data.

Question: can anyone give me a kick-start?

Edit: You can download an example of actual data here. Just Flatten[Import[filename,"Table"]]

From an experiment i have a dataset of beat-to-beat heart rate data: a list of the time between each heart beat in [ms]. The data is measured using an infrared optic sensor at the finger tip. The sensor frequently misinterprets a slight movement of the finger as an heart beat. Data therefore often looks somewhat like this:

{1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 600, 400, 1000}

In this exaple one can easily see that the 5th and 6th element should be one, same for the 10th and 11th. However, in real life the data looks more like this:

data={981, 870, 1099, 1105, 650, 397, 920, 917, 1015, 1085, 210, 344, 457,
950}

Where the 5-6 (650,397) and 11-12-13 (210,344,457) should be taken together. It is easy to just delete the incorrect data by using someting like:

DeleteCases[data,
x_ /; x < Mean[data] - StandardDeviation[data] || 
x > Mean[data] + StandardDeviation[data]]

...but i want to make a function that recognizes when multiple elements should be added to one.

One could just add every two, three or four (=length) elements and select the Cases where the result lies (for example) in the range Mean[data]-/+StandardDeviation[data]:

length = 2;
Position[Total[data[[# ;; # + length]]] & /@ 
  Range[Length[data] - length], 
 x_ /; x > Mean[data] - StandardDeviation[data] && 
   x < Mean[data] + StandardDeviation[data]]

Result:

{{5}, {11}, {12}}

This gives me an idea of where the incorrect data is. Unfortunately, after having this result, i don't know what to do with it... For example, i get confused by the fact that elements 11-12-13 return 2 cases of incorrect data when i use length=1. And maybe there are more (simple) ways to filter this data.

Question: can anyone give me a kick-start?

Edit: You can download an example of actual data here. Just Flatten[Import[filename,"Table"]]

From an experiment, I have a dataset of beat-to-beat heart rate data: a list of the time between each heart beat in [ms]. The data is measured using an infrared optic sensor at the finger tip. The sensor frequently misinterprets a slight movement of the finger as an heart beat. Data therefore often looks somewhat like this:

{1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 600, 400, 1000}

In this example, one can easily see that the 5th and 6th element should be one; same for the 10th and 11th. However, in real life the data looks more like this:

data = {981, 870, 1099, 1105, 650, 397, 920, 917, 1015, 1085, 210, 344, 457,
950}

where the 5-6 (650, 397) and 11-12-13 (210, 344, 457) should be taken together. It is easy to just delete the incorrect data by using something like:

DeleteCases[data,
x_ /; x < Mean[data] - StandardDeviation[data] || 
x > Mean[data] + StandardDeviation[data]]

...but I want to make a function that recognizes when multiple elements should be added to one.

One could just add every two, three or four (=length) elements and select the Cases where the result lies (for example) in the range Mean[data]±StandardDeviation[data]:

length = 2;
Position[Total[data[[# ;; # + length]]] & /@ 
  Range[Length[data] - length], 
 x_ /; x > Mean[data] - StandardDeviation[data] && 
   x < Mean[data] + StandardDeviation[data]]

Result:

{{5}, {11}, {12}}

This gives me an idea of where the incorrect data is. Unfortunately, after having this result, I don't know what to do with it... For example, I get confused by the fact that elements 11-12-13 return 2 cases of incorrect data when I use length=1. And maybe there are more (simple) ways to filter this data.

Question: can anyone give me a kick-start?

Edit: You can download an example of actual data here. Just Flatten[Import[filename,"Table"]]

changed .mx file to .txt
Source Link
Aart Goossens
  • 1.6k
  • 12
  • 21
Loading
Tweeted twitter.com/#!/StackMma/status/268846893495357441
added example data for download
Source Link
Aart Goossens
  • 1.6k
  • 12
  • 21
Loading
Source Link
Aart Goossens
  • 1.6k
  • 12
  • 21
Loading