Automatic Fibre Counting With Machine Learning

This work is part of a joint project with Staffordshire University. It wouldn’t have been possible without the help of Claire Gwinnett, Andrew Jackson, Jolien Casteele, Zoe Jones and Mohamed Sedky.

“Every contact leaves a trace” - (a paraphrase of) Locard’s exchange principle

Whenever you touch anything - anything - you leave some evidence behind and take some evidence with you. When it comes to contact with cloth, that might come in the form of fibres that transfer between surfaces. In Forensic Science, “persistence and transfer” studies aim to discover the mechanics of this. These studies typically involve manually counting fluorescent fibres under magnification.

This blog post introduces a prototype Neural Network-based model for counting the fibres automatically - to speed experiments up and make results more easily reproducible. I focussed on fibres ‘lifted’ from surfaces with sticky tape. Running on a GPU, the model can count fibres in a 12cm x 5cm area in ~3-6 seconds.


Does Curry Help?

It’s been two and a half years since I wrote Why Curry Helps - a little love letter to the power of using curried functions in JavaScript. It’s easily my most-read post, bringing in hundreds of readers every month.

But as time has passed, the world has changed, and so have I. Is it still a good idea to lean on this technique to squeeze more expressivity out of your code?

I’m not so convinced.


Arrow Function Semantics

In the last post, we took a deep-dive into the syntax of JavaScript’s new arrow functions. It’s great to see a new language feature that’s able to remove so much boilerplate from an idiomatic ES5 example.

But arrow functions are much more than function expressions with a fresh coat of paint. On top of the new appearance, there are some significant differences in the way they behave too.

This post explores these new behaviours; including why arrow functions don’t have their own values for this or arguments, and what that means for the code you write.


Arrow Function Syntax

The next version of JavaScript - called ES2015 (née ES6) - has just shipped. It’s final, so there won’t be any semantic or syntactic changes. What there will be are plenty of great features that coming to a JavaScript engine near you. Soon.

Even for engines that don’t implement ES2015 yet, you can use Babel to compile lots of those features into valid ES5 (the previous generation of JavaScript). This lets you run code levering the new goodness in all modern browsers, Node.js and most other places where JavaScript is used.

I’m a programmer who uses functions like a preschooler uses glitter, so arrow functions is one of the features I’m really excited about. Here’s what I’ve learnt from reading the specification, reading forum discussions and testing things out in the Babel playground.


Why Curry Helps

A programmer’s pipe-dream is to write code, and be able to use it repeatedly with little effort. It’s expressive because you write in a way that expresses what is needed, and it’s reuse because.. well, you’re reusing. What more could you want?

curry can help.


Vars And Values

Sometimes I hear JavaScript dev throw around the terms vars and values as synonyms for each other. Realising that they’re not was a serious ‘aha’ moment for me - and making the distinction about it can make talking and thinking about code clearer by far.


Tapping Into The Method Chain

Objects and methods are a big deal. They’re the core way in which JavaScript defines functionality against a type; which is reflected in the standard library, in many of the libraries we choose to use, and how production code tends to be written (at least, in my experience).

Compare these two solutions for returning the name of all the audiophiles in a contact book:


Jslint Is Not A Code Quality Tool For 3rd Party Code

Doug Crockford’s JSLint performs static analysis on Javascript, returning a list of what Crockford considers to be violations of best practice. Contrary to the assertions of its creator, however, it is not a fit tool by which to judge the quality of 3rd party code.


Prototypes: The Short(est Possible) Story

Prototypal inheritance is a brilliantly simple concept. Javascript’s syntax, however, often confuses new-comers. Let’s solve that, ehy?