Computed activity fields

Hi All,

I imagine this is a really basic question but i just don’t understand why this isnt working. Any help for a complete java beginner much appreciated!!

I am recording a field called “Bloodglucose” to my FIT file using the xdrip+ add in on my garmin watch.

The field is called “Bloodglucose” and i can see this when i open the file in fitfileviewer. I am trying to follow the above guidance in order to create fields for a) time spent below 4, b)time spent above 10, c) time spent in range. But im struggling to access the data at all using the below:

//limits
Low_limit=4
High_limit=10
//get streams
Blood_glucose= streams.get(“Bloodglucose”).data

//calculate time spent
let time_low=0
for(let i=0; i<Blood_glucose.length; i++) {
let t=Blood_glucose[i]
if (t<=Low_limit) time_low +=1
}

But i keep getting the error “Invalid stream type [Bloodglucose]” - but this steam definitely exists when i view the FIT file in fitfileviewer. Any ideas what i’m doing wrong?

Thanks for the help,
Rhys

“Custom Streams”, i.e. those not currently in the list (can inspect network activity to see ones available - see screenshot) are not yet supported.

Thats a shame - thanks for the info though!

What are the units for that field?

Units i use (and commonly used in Europe) are mmol/L.

(The US typically use mg/dL)

I have added support for “Bloodglucose”. You need to do Actions → Reprocess File to get the new trace. Then click “Charts” to add it.

3 Likes

Hi David - this is fantastic! Really appreciate this!

1 Like

Hi David,

Just coming back to this. Your example works great, but when I try to pass a fatigue value in the URL I get a 422 error Invalid fatigue. Any ideas? As an example I’m just passing the value 3000.

I can’t get this to work in R or using swagger.

Cheers

John

You need to do fatigue=kj0 or fatigue=kj1 to get fatigued power curves for the athlete. These correspond to whatever has been configured on the /power page for the athlete:

The payload does include the actual kJ values.

1 Like

Ah. thanks I get it now. Works perfectly (and agrees with my own calcs :slight_smile: )

1 Like

Custom activity field are evaluated only when I add the field, otherwise on all other activities, I have the filed empty with a question mark like this

Screenshot 2023-05-17 alle 15.41.28

Second, why I can able to edit that value? Can I set it as read only?

You need to reanalyse the old activities, you can do it on each one or there’s a way to do it in bulk too

1 Like

But I don’t want to loose al the intervals that I fixed

Ok, I’ve just saw that I can keep the existing intervals, tnx :stuck_out_tongue:

2 Likes

The fit file session field name is now a drop down that auto populates with the names of all the fields in the file session message:

4 Likes

WoW!!!

1 Like

I’ve tried a little bit to add a custom field but so far have failed. To be fair, I don’t really know how to start anyway.

I want to show the best 20min Power of the activity. And another field with best 20min Heartrate. And maybe other durations as well.

Is this possible?

Yes both of those are easy. I started with ActivityJsData from the server side data model and then looked at JsHRCurve and JsPowerCurve.

Best 20m power:

{
  icu.powerCurve.getWatts(20 * 60)
}

Best 20m HR:

{
  icu.hrCurve.getBpm(20 * 60)
}

Thanks,this works great!
That was so much better then what I was trying to do by calculating it of of the HR and Power streams myself.

1 Like

Hi!
When I use custom stream with “left_power_phase” record field, I successfully get the start angle. But this record field contains two values - start and end angle and I can’t use the second one. left_power_phase[1] give me none, preprocess fit file not helped.
Sorry for bad English.