The term "Neshama" has 2 possible meanings: It is popularly used to describe the soul in a general sense. However, there is a specific aspect of the soul which is also referred to as Neshama, as we find in the following Midrash:
חֲמִשָּׁה שֵׁמוֹת נִקְרְאוּ לָהּ: נֶפֶשׁ, רוּחַ, נְשָׁמָה, יְחִידָה, חַיָּה. נֶפֶשׁ, זֶה הַדָּם, שֶׁנֶּאֱמַר (דברים יב, כג): כִּי הַדָּם הוּא הַנֶּפֶשׁ. רוּחַ, שֶׁהִיא עוֹלָה וְיוֹרֶדֶת, שֶׁנֶּאֱמַר (קהלת ג, כא): מִי יוֹדֵעַ רוּחַ בְּנֵי אָדָם הָעוֹלָה הִיא לְמַעְלָה. נְשָׁמָה, זוֹ הָאוֹפִיָּא, דִּבְרִיָּתָא אָמְרִין הָאוֹפִיתָא טָבָא. חַיָּה, שֶׁכָּל הָאֵבָרִים מֵתִים וְהִיא חַיָּה בַּגּוּף. יְחִידָה, שֶׁכָּל הָאֵבָרִים מִשְׁנַיִם שְׁנַיִם, וְהִיא יְחִידָה בַּגּוּף.
It [the soul] has five names: nefesh, neshamah, hayyah, ruah, yehidah. Nefesh is the blood: For the blood is the nefesh — E.V. 'life' (Deut. xii, 23). Ruah: this is so called because it ascends and descends: thus it is written, Who knoweth the ruah (E.V. 'spirit') of man whether it goeth upwards, and the ruah of the beast whether it goeth downward to the earth (Eccl. in, 21) ? Neshamah is the breath; as people say, His breathing is good. Hayyah (lit. 'living'): because all the limbs are mortal, whereas this is immortal in the body. Yehidah (unique): because all the limbs are duplicated, whereas this is unique in the body. (Sefaria)
While the Midrash could be understood to merely refer to different names which all describe different aspects of the same thing, in Kabbalistic thought it is understood that the soul is actually comprised of different parts, and that each of these names refers to one of them. I've come across this concept many times, but I don't know the original source.
I believe that there is also an idea found in Kabbalistic sources that the Nefesh part of the soul is the general life force, which is associated with the blood and can be said to reside in the entire body. The Neshama is the intellectual force, and is 'located' in the brain. I also believe that the proponents of this idea cite [the students of] Rabbeinu Yona's commentary on the Rif in Brachot (8a of the Rif, which corresponds to the Gemara at the end of 14b): "The Neshama, which is in the brain" - which is also the source of the S.A. you mentioned.
So in summary, according to this view, the Gemara is using "Neshama" in its more broad sense, while the S.A. is using the more specific meaning of the term, the intellectual force which is connected to the mind.