It's a figurative speech.
Literally, 筋 is tendon, through which our brain controls our body parts, arms, fingers, legs, feet and etc. 根 is the measure word, like 一根，两根，...
The usage of 筋 can be extended. Imagine that there are thousands of "tendons" in our head that control every aspect of functionalities of our brain with regards to thinking and feelings. When we lost/missed one of them (少根筋 or 没那根筋), we would lose one of functionalities of our brain, which will cause that we behave differently from a normal person. So, 少根筋 or 没那根筋, depending on context, can mean someone either can not do something well, not have a knack for doing something or behaves odd, being insane. There is a slight difference between 少根筋 and 没那根筋. 少根筋 doesn't specify the aspect, which is why it's often been interpreted as odd or insane. Well, 没那根筋 has specified the particular aspect of tendon(our mindset) and it's often been interpreted as not having a knack for doing something. Usually, 没那根筋 is used when the context is clear about what aspect it refers to.
Here are some examples:
他脑袋少根筋 // he behaves odd, silly and etc.
我学不好数学, 我脑袋里面没有那根筋 // I can not do math well, because I don't have a knack for it(I don't have that tendon in my head for math). (the aspect[数学] is clear in this context.)
一根筋 means one only have one way to do something, do something in a clumsy way. Imagine one has only one "tendon"(mindset) in his brain to control everything. But it can have a positive meaning, because it can denote one's persistence and perseverance. For example:
他做事情就一根筋 // he only stick to one approach/principle to do something.