OSCR

BetaII-spectrin gaps and patches emerge from the patterned assembly of the actin/spectrin membrane skeleton in human motor neuron axons.

Code ↔ Paper

1 match between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 1 match
  1. [1] § Materials and methods › MPS organization assessment › MPS organization assessment by ‘Gollum’ () ↔ ringfinder/ringFinder.py, lines 452–594 · score 0.50 · Pearson correlation coefficient, Gollum, tool

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 676 lines · 29 KB · GPL-3.0 · 1 match

  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Fri Jul 15 12:25:40 2016
  4. @author: Luciano Masullo, Federico Barabas
  5. """
  6. import os
  7. import time
  8. import math
  9. import numpy as np
  10. from scipy import ndimage as ndi
  11. import tifffile as tiff
  12. from PIL import Image
  13. import pyqtgraph as pg
  14. from pyqtgraph.Qt import QtGui, QtCore
  15. import matplotlib.pyplot as plt
  16. import matplotlib.colors
  17. # from matplotlib import rc
  18. import ringfinder.utils as utils
  19. import ringfinder.tools as tools
  20. import ringfinder.pyqtsubclass as pyqtsub
  21. # rc('text', usetex=True)
  22. # rc('font', **{'family': 'serif', 'serif': ['Computer Modern'], 'size': 15})
  23. class Gollum(QtGui.QMainWindow):
  24. def __init__(self, *args, **kwargs):
  25. super().__init__(*args, **kwargs)
  26. self.i = 0
  27. self.testData = False
  28. self.setWindowTitle('Gollum: the Ring Finder')
  29. self.cwidget = QtGui.QWidget()
  30. self.setCentralWidget(self.cwidget)
  31. menubar = self.menuBar()
  32. fileMenu = menubar.addMenu('&Run')
  33. batchSTORMAct = QtGui.QAction('Analyze batch of STORM images...', self)
  34. batchSTEDAct = QtGui.QAction('Analyze batch of STED images...', self)
  35. batchSTORMAct.triggered.connect(self.batchSTORM)
  36. batchSTEDAct.triggered.connect(self.batchSTED)
  37. fileMenu.addAction(batchSTORMAct)
  38. fileMenu.addAction(batchSTEDAct)
  39. fileMenu.addSeparator()
  40. exitAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self)
  41. exitAction.setShortcut('Ctrl+Q')
  42. exitAction.setStatusTip('Exit application')
  43. exitAction.triggered.connect(QtGui.QApplication.closeAllWindows)
  44. fileMenu.addAction(exitAction)
  45. self.folderStatus = QtGui.QLabel('Ready', self)
  46. self.statusBar().addPermanentWidget(self.folderStatus, 1)
  47. self.fileStatus = QtGui.QLabel('Ready', self)
  48. self.statusBar().addPermanentWidget(self.fileStatus)
  49. # Main Widgets' layout
  50. self.mainLayout = QtGui.QGridLayout()
  51. self.cwidget.setLayout(self.mainLayout)
  52. # Image with correlation results
  53. self.corrImgWidget = pg.GraphicsLayoutWidget()
  54. self.corrImgItem = pg.ImageItem()
  55. self.corrVb = self.corrImgWidget.addViewBox(col=0, row=0)
  56. self.corrVb.setAspectLocked(True)
  57. self.corrVb.addItem(self.corrImgItem)
  58. self.corrImgHist = pg.HistogramLUTItem()
  59. self.corrImgHist.gradient.loadPreset('thermal')
  60. self.corrImgHist.setImageItem(self.corrImgItem)
  61. self.corrImgHist.vb.setLimits(yMin=0, yMax=20000)
  62. self.corrImgWidget.addItem(self.corrImgHist)
  63. self.corrResult = pg.ImageItem()
  64. self.corrVb.addItem(self.corrResult)
  65. # Image with ring results
  66. self.ringImgWidget = pg.GraphicsLayoutWidget()
  67. self.ringImgItem = pg.ImageItem()
  68. self.ringVb = self.ringImgWidget.addViewBox(col=0, row=0)
  69. self.ringVb.setAspectLocked(True)
  70. self.ringVb.addItem(self.ringImgItem)
  71. self.ringImgHist = pg.HistogramLUTItem()
  72. self.ringImgHist.gradient.loadPreset('thermal')
  73. self.ringImgHist.setImageItem(self.ringImgItem)
  74. self.ringImgHist.vb.setLimits(yMin=0, yMax=20000)
  75. self.ringImgWidget.addItem(self.ringImgHist)
  76. self.ringResult = pg.ImageItem()
  77. self.ringVb.addItem(self.ringResult)
  78. # Separate frame for loading controls
  79. loadTitle = QtGui.QLabel('<b><u>Load Image</u></b>')
  80. loadTitle.setTextFormat(QtCore.Qt.RichText)
  81. loadTitle.setAlignment(QtCore.Qt.AlignCenter)
  82. loadTitle.setStyleSheet("font-size:14px")
  83. self.STORMPxEdit = QtGui.QLineEdit()
  84. self.magnificationEdit = QtGui.QLineEdit()
  85. self.loadSTORMButton = QtGui.QPushButton('Load')
  86. self.loadSTORMButton.setSizePolicy(QtGui.QSizePolicy.Preferred,
  87. QtGui.QSizePolicy.Expanding)
  88. self.STEDPxEdit = QtGui.QLineEdit()
  89. self.loadSTEDButton = QtGui.QPushButton('Load')
  90. # Ring finding method settings frame
  91. self.intThrLabel = QtGui.QLabel('#sigmas threshold from mean')
  92. self.intThresEdit = QtGui.QLineEdit()
  93. self.sigmaEdit = QtGui.QLineEdit()
  94. self.lineLengthEdit = QtGui.QLineEdit()
  95. self.roiSizeEdit = QtGui.QLineEdit()
  96. self.corrSlider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
  97. self.corrSlider.setMinimum(0)
  98. self.corrSlider.setMaximum(250) # Divide by 1000 to get corr value
  99. self.corrSlider.setValue(200)
  100. self.corrThresEdit = QtGui.QLineEdit()
  101. self.minAreaEdit = QtGui.QLineEdit()
  102. self.corrSlider.valueChanged[int].connect(self.sliderChange)
  103. self.showCorrMapCheck = QtGui.QCheckBox('Show coefficient map', self)
  104. self.thetaStepEdit = QtGui.QLineEdit()
  105. self.deltaThEdit = QtGui.QLineEdit()
  106. self.sinPowerEdit = QtGui.QLineEdit()
  107. self.corrButton = QtGui.QPushButton('Run analysis')
  108. self.corrButton.setCheckable(True)
  109. self.corrButton.setFixedHeight(28)
  110. settingsTitle = QtGui.QLabel('<b><u>Ring finding settings</u></b>')
  111. settingsTitle.setTextFormat(QtCore.Qt.RichText)
  112. settingsTitle.setAlignment(QtCore.Qt.AlignCenter)
  113. settingsTitle.setStyleSheet("font-size:14px")
  114. wvlenLabel = QtGui.QLabel('Rings periodicity [nm]')
  115. self.wvlenEdit = QtGui.QLineEdit()
  116. corrThresLabel = QtGui.QLabel('Discrimination threshold')
  117. # Load settings configuration and then connect the update
  118. try:
  119. tools.loadConfig(self)
  120. except:
  121. tools.saveDefaultConfig()
  122. tools.loadConfig(self)
  123. self.STORMPxEdit.editingFinished.connect(self.updateConfig)
  124. self.magnificationEdit.editingFinished.connect(self.updateConfig)
  125. self.STEDPxEdit.editingFinished.connect(self.updateConfig)
  126. self.roiSizeEdit.editingFinished.connect(self.updateConfig)
  127. self.sigmaEdit.editingFinished.connect(self.updateConfig)
  128. self.intThresEdit.editingFinished.connect(self.updateConfig)
  129. self.lineLengthEdit.editingFinished.connect(self.updateConfig)
  130. self.wvlenEdit.editingFinished.connect(self.updateConfig)
  131. self.sinPowerEdit.editingFinished.connect(self.updateConfig)
  132. self.thetaStepEdit.editingFinished.connect(self.updateConfig)
  133. self.deltaThEdit.editingFinished.connect(self.updateConfig)
  134. self.corrThresEdit.editingFinished.connect(self.updateConfig)
  135. self.buttonWidget = QtGui.QWidget()
  136. buttonsLayout = QtGui.QGridLayout()
  137. self.buttonWidget.setLayout(buttonsLayout)
  138. buttonsLayout.addWidget(loadTitle, 0, 0, 1, 3)
  139. buttonsLayout.addWidget(
  140. QtGui.QLabel('<b>STORM</b> pixel size [nm]'), 1, 0)
  141. buttonsLayout.addWidget(self.STORMPxEdit, 1, 1)
  142. buttonsLayout.addWidget(
  143. QtGui.QLabel('<b>STORM</b> magnification'), 2, 0)
  144. buttonsLayout.addWidget(self.magnificationEdit, 2, 1)
  145. buttonsLayout.addWidget(self.loadSTORMButton, 1, 2, 2, 1)
  146. buttonsLayout.addWidget(
  147. QtGui.QLabel('<b>STED</b> pixel size [nm]'), 3, 0)
  148. buttonsLayout.addWidget(self.STEDPxEdit, 3, 1)
  149. buttonsLayout.addWidget(self.loadSTEDButton, 3, 2)
  150. buttonsLayout.addWidget(settingsTitle, 5, 0, 1, 3)
  151. buttonsLayout.addWidget(wvlenLabel, 6, 0, 1, 2)
  152. buttonsLayout.addWidget(self.wvlenEdit, 6, 2)
  153. buttonsLayout.addWidget(corrThresLabel, 7, 0, 1, 2)
  154. buttonsLayout.addWidget(self.corrThresEdit, 7, 2)
  155. buttonsLayout.addWidget(self.corrSlider, 8, 0, 1, 3)
  156. buttonsLayout.addWidget(self.showCorrMapCheck, 9, 0, 1, 3)
  157. buttonsLayout.addWidget(self.corrButton, 10, 0, 1, 3)
  158. buttonsLayout.setRowMinimumHeight(4, 20)
  159. buttonsLayout.setColumnMinimumWidth(0, 140)
  160. self.buttonWidget.setFixedWidth(270)
  161. # layout of the three widgets
  162. self.mainLayout.addWidget(self.buttonWidget, 1, 0)
  163. corrLabel = QtGui.QLabel('Pearson coefficient')
  164. corrLabel.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter)
  165. self.mainLayout.addWidget(corrLabel, 0, 1)
  166. self.mainLayout.addWidget(self.corrImgWidget, 1, 1, 2, 1)
  167. ringLabel = QtGui.QLabel('Rings')
  168. ringLabel.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter)
  169. self.mainLayout.addWidget(ringLabel, 0, 2)
  170. self.mainLayout.addWidget(self.ringImgWidget, 1, 2, 2, 1)
  171. self.mainLayout.setColumnMinimumWidth(1, 600)
  172. self.mainLayout.setColumnMinimumWidth(2, 600)
  173. self.loadSTORMButton.clicked.connect(self.loadSTORM)
  174. self.loadSTEDButton.clicked.connect(self.loadSTED)
  175. self.sigmaEdit.textChanged.connect(self.updateMasks)
  176. self.corrButton.clicked.connect(self.ringFinder)
  177. # Load sample STED image
  178. folder = os.path.join(os.getcwd(), 'ringfinder')
  179. if os.path.exists(folder):
  180. self.folder = folder
  181. self.loadSTED(os.path.join(folder, 'spectrinSTED.tif'))
  182. else:
  183. self.folder = os.getcwd()
  184. self.loadSTED(os.path.join(os.getcwd(), 'spectrinSTED.tif'))
  185. def updateConfig(self):
  186. tools.saveConfig(self)
  187. def sliderChange(self, value):
  188. self.corrThresEdit.setText(str(np.round(0.001*value, 2)))
  189. self.corrEditChange(str(value/1000))
  190. def corrEditChange(self, text):
  191. self.corrSlider.setValue(1000*float(text))
  192. if self.analyzed:
  193. self.corrThres = float(text)
  194. self.ringsBig = np.nan_to_num(self.localCorrBig) > self.corrThres
  195. self.ringsBig = self.ringsBig.astype(float)
  196. self.ringResult.setImage(np.fliplr(np.transpose(self.ringsBig)))
  197. def loadSTED(self, filename=None):
  198. self.loadImage(np.float(self.STEDPxEdit.text()), 'STED',
  199. filename=filename)
  200. def loadSTORM(self, filename=None):
  201. # The STORM image has black borders because it's not possible to
  202. # localize molecules near the edge of the widefield image.
  203. # Therefore we need to crop those 3px borders before running the
  204. # analysis.
  205. mag = np.float(self.magnificationEdit.text())
  206. load = self.loadImage(np.float(self.STORMPxEdit.text()), 'STORM',
  207. crop=int(3*mag), filename=filename)
  208. if load:
  209. self.corrImgHist.setLevels(0, 3)
  210. self.ringImgHist.setLevels(0, 3)
  211. def loadImage(self, pxSize, tt, crop=0, filename=None):
  212. try:
  213. if not(isinstance(filename, str)):
  214. filetypes = ('Tiff file', '*.tif;*.tiff')
  215. self.filename = utils.getFilename('Load ' + tt + ' image',
  216. [filetypes], self.folder)
  217. else:
  218. self.filename = filename
  219. if self.filename is not None:
  220. self.corrButton.setChecked(False)
  221. self.analyzed = False
  222. self.folder = os.path.split(self.filename)[0]
  223. self.crop = np.int(crop)
  224. self.pxSize = pxSize
  225. self.corrVb.clear()
  226. self.corrResult.clear()
  227. self.ringVb.clear()
  228. self.ringResult.clear()
  229. im = Image.open(self.filename)
  230. self.inputData = np.array(im).astype(np.float64)
  231. self.initShape = self.inputData.shape
  232. bound = (np.array(self.initShape) - self.crop).astype(np.int)
  233. self.inputData = self.inputData[self.crop:bound[0],
  234. self.crop:bound[1]]
  235. self.shape = self.inputData.shape
  236. # We need 1um n-sized subimages
  237. self.subimgPxSize = int(1000/self.pxSize)
  238. self.n = (np.array(self.shape)/self.subimgPxSize).astype(int)
  239. # If n*subimgPxSize < shape, we crop the image
  240. self.remanent = np.array(self.shape) - self.n*self.subimgPxSize
  241. self.inputData = self.inputData[:self.n[0]*self.subimgPxSize,
  242. :self.n[1]*self.subimgPxSize]
  243. self.shape = self.inputData.shape
  244. self.nblocks = np.array(self.inputData.shape)/self.n
  245. self.blocksInput = tools.blockshaped(self.inputData,
  246. *self.nblocks)
  247. self.updateMasks()
  248. self.corrVb.addItem(self.corrImgItem)
  249. self.ringVb.addItem(self.ringImgItem)
  250. showIm = np.fliplr(np.transpose(self.inputData))
  251. self.corrImgItem.setImage(showIm)
  252. self.ringImgItem.setImage(showIm)
  253. self.grid = pyqtsub.Grid(self.corrVb, self.shape, self.n)
  254. self.corrVb.setLimits(xMin=-0.05*self.shape[0],
  255. xMax=1.05*self.shape[0], minXRange=4,
  256. yMin=-0.05*self.shape[1],
  257. yMax=1.05*self.shape[1], minYRange=4)
  258. self.ringVb.setLimits(xMin=-0.05*self.shape[0],
  259. xMax=1.05*self.shape[0], minXRange=4,
  260. yMin=-0.05*self.shape[1],
  261. yMax=1.05*self.shape[1], minYRange=4)
  262. self.dataMean = np.mean(self.inputData)
  263. self.dataStd = np.std(self.inputData)
  264. self.corrVb.addItem(self.corrResult)
  265. self.ringVb.addItem(self.ringResult)
  266. return True
  267. else:
  268. return False
  269. except OSError:
  270. self.fileStatus.setText('No file selected!')
  271. def updateMasks(self):
  272. """Binarization of image. """
  273. self.gaussSigma = np.float(self.sigmaEdit.text())/self.pxSize
  274. thr = np.float(self.intThresEdit.text())
  275. if self.testData:
  276. self.blocksInputS = [ndi.gaussian_filter(b, self.gaussSigma)
  277. for b in self.blocksInput]
  278. self.blocksInputS = np.array(self.blocksInputS)
  279. self.meanS = np.mean(self.blocksInputS, (1, 2))
  280. self.stdS = np.std(self.blocksInputS, (1, 2))
  281. thresholds = self.meanS + thr*self.stdS
  282. thresholds = thresholds.reshape(np.prod(self.n), 1, 1)
  283. mask = self.blocksInputS < thresholds
  284. self.blocksMask = np.array([bI < np.mean(bI) + thr*np.std(bI)
  285. for bI in self.blocksInputS])
  286. self.mask = tools.unblockshaped(mask, *self.inputData.shape)
  287. self.inputDataS = tools.unblockshaped(self.blocksInputS,
  288. *self.shape)
  289. else:
  290. self.inputDataS = ndi.gaussian_filter(self.inputData,
  291. self.gaussSigma)
  292. self.blocksInputS = tools.blockshaped(self.inputDataS,
  293. *self.nblocks)
  294. self.meanS = np.mean(self.inputDataS)
  295. self.stdS = np.std(self.inputDataS)
  296. self.mask = self.inputDataS < self.meanS + thr*self.stdS
  297. self.blocksMask = tools.blockshaped(self.mask, *self.nblocks)
  298. self.showImS = np.fliplr(np.transpose(self.inputDataS))
  299. self.showMask = np.fliplr(np.transpose(self.mask))
  300. def ringFinder(self, show=True, batch=False):
  301. """RingFinder handles the input data, and then evaluates every subimg
  302. using the given algorithm which decides if there are rings or not.
  303. Subsequently gives the output data and plots it"""
  304. if self.corrButton.isChecked() or batch:
  305. self.corrResult.clear()
  306. self.ringResult.clear()
  307. # for each subimg, we apply the correlation method for ring finding
  308. intThr = np.float(self.intThresEdit.text())
  309. minLen = np.float(self.lineLengthEdit.text())/self.pxSize
  310. thetaStep = np.float(self.thetaStepEdit.text())
  311. deltaTh = np.float(self.deltaThEdit.text())
  312. wvlen = np.float(self.wvlenEdit.text())/self.pxSize
  313. sinPow = np.float(self.sinPowerEdit.text())
  314. cArgs = minLen, thetaStep, deltaTh, wvlen, sinPow
  315. # Single-core code
  316. self.localCorr = np.zeros(len(self.blocksInput))
  317. thres = self.meanS + intThr*self.stdS
  318. if not(self.testData):
  319. thres = thres*np.ones(self.blocksInput.shape)
  320. for i in np.arange(len(self.blocksInput)):
  321. block = self.blocksInput[i]
  322. blockS = self.blocksInputS[i]
  323. mask = self.blocksMask[i]
  324. # Block may be excluded from the analysis for two reasons.
  325. # Firstly, because the intensity for all its pixels may be
  326. # too low. Secondly, because the part of the block that
  327. # belongs toa neuron may be below an arbitrary 20% of the
  328. # block. We apply intensity threshold to smoothed data so we
  329. # don't catch tiny bright spots outside neurons
  330. neuronFrac = 1 - np.sum(mask)/np.size(mask)
  331. areaThres = 0.01*float(self.minAreaEdit.text())
  332. if np.any(blockS > thres[i]) and neuronFrac > areaThres:
  333. output = tools.corrMethod(block, mask, *cArgs)
  334. angle, corrTheta, corrMax, theta, phase = output
  335. # Store results
  336. self.localCorr[i] = corrMax
  337. else:
  338. self.localCorr[i] = np.nan
  339. self.localCorr = self.localCorr.reshape(*self.n)
  340. self.updateGUI(self.localCorr)
  341. else:
  342. self.corrResult.clear()
  343. self.ringResult.clear()
  344. def updateGUI(self, localCorr):
  345. self.analyzed = True
  346. self.localCorr = localCorr
  347. # code for visualization of the output
  348. mag = np.array(self.inputData.shape)/self.n
  349. self.localCorrBig = np.repeat(self.localCorr, mag[0], 0)
  350. self.localCorrBig = np.repeat(self.localCorrBig, mag[1], 1)
  351. showIm = 100*np.fliplr(np.transpose(self.localCorrBig))
  352. self.corrResult.setImage(np.nan_to_num(showIm))
  353. self.corrResult.setZValue(10) # make sure this image is on top
  354. self.corrResult.setOpacity(0.5)
  355. self.corrThres = float(self.corrThresEdit.text())
  356. self.ringsBig = np.nan_to_num(self.localCorrBig) > self.corrThres
  357. self.ringsBig = self.ringsBig.astype(float)
  358. self.ringResult.setImage(np.fliplr(np.transpose(self.ringsBig)))
  359. self.ringResult.setZValue(10) # make sure this image is on top
  360. self.ringResult.setOpacity(0.5)
  361. if self.showCorrMapCheck.isChecked():
  362. plt.figure(figsize=(10, 8))
  363. data = self.localCorr.reshape(*self.n)
  364. data = np.flipud(data)
  365. maskedData = np.ma.array(data, mask=np.isnan(data))
  366. mx = np.max(maskedData)
  367. mn = np.min(maskedData)
  368. mp = (self.corrThres - mn)/(mx - mn)
  369. mp = np.min((mp, 1))
  370. mp = np.max((mp, 0))
  371. cmap = shiftedColorMap(matplotlib.cm.PuOr, midpoint=mp,
  372. name='shifted')
  373. heatmap = plt.pcolor(maskedData, cmap=cmap)
  374. for y in range(data.shape[0]):
  375. for x in range(data.shape[1]):
  376. plt.text(x + 0.5, y + 0.5, '%.2f' % data[y, x],
  377. horizontalalignment='center',
  378. verticalalignment='center',)
  379. plt.colorbar(heatmap)
  380. plt.gca().set_xticklabels([])
  381. plt.gca().set_yticklabels([])
  382. plt.show()
  383. def batch(self, function, tech):
  384. try:
  385. filenames = utils.getFilenames('Load ' + tech + ' images',
  386. [('Tiff file', '*.tif;*.tiff')],
  387. self.folder)
  388. nfiles = len(filenames)
  389. function(filenames[0])
  390. corrArray = np.zeros((nfiles, self.n[0], self.n[1]))
  391. # Expand correlation array so it matches data shape
  392. corrExp = np.empty((nfiles, self.initShape[0], self.initShape[1]),
  393. dtype=np.single)
  394. corrExp[:] = np.nan
  395. ringsExp = np.empty((nfiles, self.initShape[0], self.initShape[1]),
  396. dtype=np.single)
  397. ringsExp[:] = np.nan
  398. path = os.path.split(filenames[0])[0]
  399. folder = os.path.split(path)[1]
  400. self.folderStatus.setText('Processing folder ' + path)
  401. print('Processing folder', path)
  402. t0 = time.time()
  403. # Make results directory if it doesn't exist
  404. resultsDir = os.path.join(path, 'results')
  405. if not os.path.exists(resultsDir):
  406. os.makedirs(resultsDir)
  407. resNames = [utils.insertFolder(p, 'results') for p in filenames]
  408. for i in np.arange(nfiles):
  409. print(os.path.split(filenames[i])[1])
  410. self.fileStatus.setText(os.path.split(filenames[i])[1])
  411. function(filenames[i])
  412. self.ringFinder(False, batch=True)
  413. corrArray[i] = self.localCorr
  414. bound = (np.array(self.initShape) - self.crop).astype(np.int)
  415. edge = bound - self.remanent
  416. corrExp[i, self.crop:edge[0],
  417. self.crop:edge[1]] = self.localCorrBig
  418. # Save correlation values array
  419. corrName = utils.insertSuffix(resNames[i], '_correlation')
  420. tiff.imsave(corrName, corrExp[i], software='Gollum',
  421. imagej=True,
  422. resolution=(1000/self.pxSize, 1000/self.pxSize),
  423. metadata={'spacing': 1, 'unit': 'um'})
  424. # Saving ring images
  425. ringsExp[corrExp < self.corrThres] = 0
  426. ringsExp[corrExp >= self.corrThres] = 1
  427. for i in np.arange(nfiles):
  428. # Save correlation values array
  429. ringName = utils.insertSuffix(resNames[i], '_rings')
  430. tiff.imsave(ringName, ringsExp[i], software='Gollum',
  431. imagej=True,
  432. resolution=(1000/self.pxSize, 1000/self.pxSize),
  433. metadata={'spacing': 1, 'unit': 'um'})
  434. # save configuration file in the results folder
  435. tools.saveConfig(self, os.path.join(resultsDir, 'config'))
  436. # plot histogram of the correlation values
  437. hrange = (np.min(np.nan_to_num(corrArray)),
  438. np.max(np.nan_to_num(corrArray)))
  439. y, x, _ = plt.hist(corrArray.flatten(), bins=20, range=hrange)
  440. x = (x[1:] + x[:-1])/2
  441. # Save data array as txt
  442. corrArrayFlat = corrArray.flatten()
  443. validCorr = corrArrayFlat[~np.isnan(corrArrayFlat)]
  444. validArr = np.repeat(np.arange(nfiles), np.prod(self.n))
  445. validArr = validArr[~np.isnan(corrArrayFlat)]
  446. valuesTxt = os.path.join(resultsDir, folder + 'corr_values.txt')
  447. corrByN = np.stack((validCorr, validArr), 1)
  448. np.savetxt(valuesTxt, corrByN, fmt='%f\t%i')
  449. groupedCorr = [validCorr[np.where(validArr == i)]
  450. for i in np.arange(nfiles)]
  451. groupedCorr = [x for x in groupedCorr if len(x) > 0]
  452. nfiles = len(groupedCorr)
  453. meanCorrs = [np.mean(d) for d in groupedCorr]
  454. validCorrRing = validCorr[np.where(validCorr > self.corrThres)]
  455. validArrRing = validArr[np.where(validCorr > self.corrThres)]
  456. groupedCorrRing = [validCorrRing[np.where(validArrRing == i)]
  457. for i in np.arange(nfiles)]
  458. ringFracs = [len(groupedCorrRing[i])/len(groupedCorr[i])
  459. for i in np.arange(nfiles)]
  460. meanRingCorrs = np.array([np.mean(d) for d in groupedCorrRing])
  461. meanRingCorrs = meanRingCorrs[~np.isnan(meanRingCorrs)]
  462. n = corrArray.size - np.count_nonzero(np.isnan(corrArray))
  463. nring = np.sum(validCorr > self.corrThres)
  464. validRingCorr = validCorr[validCorr > self.corrThres]
  465. ringFrac = nring/n
  466. # Err estimation: stat err (binomial distribution, p=ringFrac)
  467. statVar = ringFrac*(1 - ringFrac)/n
  468. fracStd = math.sqrt(statVar)
  469. statCorrVar = np.var(validCorr)/n
  470. corrStd = math.sqrt(statCorrVar)
  471. statRingCorrVar = np.var(validRingCorr)/nring
  472. ringCorrStd = math.sqrt(statRingCorrVar)
  473. # Plotting
  474. plt.style.use('ggplot')
  475. plt.figure(figsize=(10, 7.5))
  476. plt.bar(x, y, align='center', width=(x[1] - x[0]), color="#3F5D7D")
  477. plt.plot((self.corrThres, self.corrThres), (0, np.max(y)), '--',
  478. color='r', linewidth=2)
  479. text = ('Pearson coefficient threshold = {0:.2f} \n'
  480. 'n = {1}; nrings = {2} \n'
  481. 'PSS fraction = {3:.2f} $\pm$ {4:.2f} \n'
  482. 'mean coefficient = {5:.3f} $\pm$ {6:.3f}\n'
  483. 'mean ring coefficient = {7:.3f} $\pm$ {8:.3f}')
  484. text = text.format(self.corrThres, n, nring,
  485. np.mean(ringFracs), fracStd,
  486. np.mean(meanCorrs), corrStd,
  487. np.mean(meanRingCorrs), ringCorrStd)
  488. plt.text(0.75*plt.axis()[1], 0.83*plt.axis()[3], text,
  489. horizontalalignment='center', verticalalignment='center',
  490. bbox=dict(facecolor='white'), fontsize=20)
  491. plt.xlabel('Pearson correlation coefficient', fontsize=35)
  492. plt.tick_params(axis='both', labelsize=25)
  493. plt.grid()
  494. plt.tight_layout()
  495. plt.savefig(os.path.join(resultsDir, folder + 'corr_hist.pdf'),
  496. dpi=300)
  497. plt.savefig(os.path.join(resultsDir, folder + 'corr_hist.png'),
  498. dpi=300)
  499. plt.close()
  500. folder = os.path.split(path)[1]
  501. text = 'Folder ' + folder + ' done in {0:.0f} seconds'
  502. print(text.format(time.time() - t0))
  503. self.folderStatus.setText(text.format(time.time() - t0))
  504. self.fileStatus.setText(' ')
  505. except IndexError:
  506. self.fileStatus.setText('No file selected!')
  507. def batchSTORM(self):
  508. self.batch(self.loadSTORM, 'STORM')
  509. def batchSTED(self):
  510. self.batch(self.loadSTED, 'STED')
  511. def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'):
  512. '''
  513. Function to offset the "center" of a colormap. Useful for
  514. data with a negative min and positive max and you want the
  515. middle of the colormap's dynamic range to be at zero
  516. Input
  517. -----
  518. cmap : The matplotlib colormap to be altered
  519. start : Offset from lowest point in the colormap's range.
  520. Defaults to 0.0 (no lower ofset). Should be between
  521. 0.0 and `midpoint`.
  522. midpoint : The new center of the colormap. Defaults to
  523. 0.5 (no shift). Should be between 0.0 and 1.0. In
  524. general, this should be 1 - vmax/(vmax + abs(vmin))
  525. For example if your data range from -15.0 to +5.0 and
  526. you want the center of the colormap at 0.0, `midpoint`
  527. should be set to 1 - 5/(5 + 15)) or 0.75
  528. stop : Offset from highets point in the colormap's range.
  529. Defaults to 1.0 (no upper ofset). Should be between
  530. `midpoint` and 1.0.
  531. http://stackoverflow.com/questions/7404116/
  532. defining-the-midpoint-of-a-colormap-in-matplotlib
  533. '''
  534. if midpoint == stop:
  535. newcmap = truncate_colormap(cmap, 0, 0.5)
  536. elif midpoint == start:
  537. newcmap = truncate_colormap(cmap, 0.5, 1)
  538. else:
  539. cdict = {
  540. 'red': [],
  541. 'green': [],
  542. 'blue': [],
  543. 'alpha': []
  544. }
  545. # regular index to compute the colors
  546. reg_index = np.linspace(start, stop, 257)
  547. # shifted index to match the data
  548. shift_index = np.hstack([
  549. np.linspace(0.0, midpoint, 128, endpoint=False),
  550. np.linspace(midpoint, 1.0, 129, endpoint=True)
  551. ])
  552. for ri, si in zip(reg_index, shift_index):
  553. r, g, b, a = cmap(ri)
  554. cdict['red'].append((si, r, r))
  555. cdict['green'].append((si, g, g))
  556. cdict['blue'].append((si, b, b))
  557. cdict['alpha'].append((si, a, a))
  558. newcmap = matplotlib.colors.LinearSegmentedColormap(name, cdict)
  559. plt.register_cmap(cmap=newcmap)
  560. return newcmap
  561. def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=256):
  562. new_cmap = matplotlib.colors.LinearSegmentedColormap.from_list(
  563. 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
  564. cmap(np.linspace(minval, maxval, n)))
  565. return new_cmap
  566. if __name__ == '__main__':
  567. app = QtGui.QApplication([])
  568. win = Gollum()
  569. win.show()
  570. app.exec_()

ringFinder.py at commit b97868c, under GPL-3.0 · at the source

Overview

Authors: Nahir Guadalupe Gazal1, Maria Jose Castellanos-Montiel2, Guillermina Bruno1, Anna Kristina Franco-Flores2, Sarah Lépine2,3, Lale Gursu2, Ghazal Haghi2, Gilles Maussion2, Wolfgang E Reintsch2, Fernando D Stefani4,5, Agustín Anastasía1,6, Mariano Bisbal1,6,7, Ezequiel Axel Gorostiza8, Thomas M Durcan2, Nicolás Unsain1,6,7
  1. Instituto de Investigación Médica Mercedes y Martín Ferreyra (INIMEC), Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET), Universidad Nacional de Córdoba Córdoba Argentina
  2. Early Drug Discovery Unit (EDDU), The Neuro-Montreal Neurological Institute and Hospital, Department of Neurology and Neurosurgery, McGill University Montreal Canada
  3. Faculty of Medicine and Health Sciences, McGill University Montreal Canada
  4. Centro de Investigaciones en Bionanociencias (CIBION), Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) Ciudad Autónoma de Buenos Aires Argentina
  5. Departamento de Física, Facultad de Ciencias Exactas y Naturales, Universidad de Buenos Aires Ciudad Autónoma de Buenos Aires Argentina
  6. Instituto Universitario de Ciencias Biomédicas de Córdoba (IUCBC) Córdoba Argentina
  7. Facultad de Ciencias Exactas, Físicas y Naturales, Universidad Nacional de Córdoba Córdoba Argentina
  8. Institute of Zoology, Biocenter Cologne, University of Cologne Cologne Germany
Journal: eLife, volume 14, article RP108021
Dates: published online 8 September 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.7554/elife.108021 · PMID 42708447 · PMCID PMC13553066 · OpenAlex W4414281024
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: human (organism), mouse (organism), cellular / molecular (subfield)
Methods: Statistics, Connectivity, fMRI & imaging
Keywords: spectrin, axon, actin, motor neurons, MPS, cytoskeleton, iPSCs, staurosporine, Human, Mouse
MeSH: Actins*, Axons*, Cytoskeleton*, Motor Neurons*, Spectrin*, Humans, Induced Pluripotent Stem Cells (* major topic)
Journal subjects: Cell Biology, Neuroscience
Topic: Cellular Mechanics and Interactions (Cell Biology, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Citations: not cited yet (Europe PMC); 61 references in the paper

Abstract

The actin/spectrin membrane-associated periodic skeleton (MPS) is a cytoskeletal structure that supports axonal integrity and function. Lower spinal motor neurons (MNs) are characterized by exceptionally long axons and are particularly susceptible to degeneration in a wide range of hereditary neuromuscular disorders, including amyotrophic lateral sclerosis. Using confocal and super-resolution imaging, we characterized the spatial distribution of βII-spectrin and the assembly pattern of the MPS in human MN axons derived from induced pluripotent stem cells. We discovered a striking gap-and-patch pattern in the medial axon, where sharply demarcated βII-spectrin gaps alternate with patches containing a well-organized MPS. The pattern is acutely induced by the kinase inhibitor staurosporine and pharmacological inhibition of actin polymerization prevents patch formation, indicating a requirement for actin nucleation in MPS assembly. Our data supports a model in which spectrin incorporation into nascent MPS patches depletes neighboring regions, producing long-range gaps-and-patches patterns.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.

cibion-conicet/Gollum

License: GPL-3.0
State: the link answers, verified on 26 September 2026
Evidence: files inventoried
Commit: b97868cff590ccdf6df0dfe61a939f85cf83a47d, 7 February 2018
Languages: Python (13)
Size: 24 files, 13 scripts
Software Heritage: not archived
Found in: the text, “MPS organization assessment by ‘Gollum’ ( Baraba”
Holds: README, license file, environment (requirements.txt)
Not found: CITATION.cff, tests, continuous integration, documentation
Tools: NumPy (7 files), SciPy (4 files), Matplotlib (3 files), Pillow (3 files), tifffile (3 files), scikit-image (1 file)
Availability: 1 check, the latest on 26 September 2026: the link answers
  • 26 September 2026: the link answers
15 files

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 13 scripts, each with its path and the digest of its content;
  • 1 match between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data availability

All data generated or analyzed during this study are included in this published article. The raw data used in this article has been deposited in the following domain: http://hdl.handle.net/11336/294857. The cell lines utilized in this work were created by the The Early Drug Discovery Unit (EDDU) at The Neuro (Montreal Neurological Institute and Hospital, McGill University). The cell lines are deposited in The Neuro C-BIG repository and are publicly available (https://www.neuro-edduportal.com/ipsc-catalogue).

The following dataset was generated:

AnastasiaA BisbalM UnsainN 2026Raw microscopy images from cultured human-derived motor neurons stained for b2-spectrin and other cytoskeletal proteins and registered by confocal and STED microsocypy: the whole set was used to produce the publication entitled "BetaII-Spectrin Gaps and Patches Emerge from the Patterned Assembly of the Actin/Spectrin Membrane Skeleton in Human Motor Neuron AxonsHandle11336/294857

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 15 authors, 10 keywords, 7 MeSH terms, 3 funders, 60 references.

Cite

This paper

Gazal, N. G., Castellanos-Montiel, M. J., Bruno, G., Franco-Flores, A. K., Lépine, S., Gursu, L., Haghi, G., Maussion, G., Reintsch, W. E., Stefani, F. D., Anastasía, A., Bisbal, M., Gorostiza, E. A., Durcan, T. M., & Unsain, N. (2026). BetaII-spectrin gaps and patches emerge from the patterned assembly of the actin/spectrin membrane skeleton in human motor neuron axons. eLife, 14, RP108021. https://doi.org/10.7554/elife.108021

BibTeX

@article{gazal2026betaii,
author = {Gazal, Nahir Guadalupe and Castellanos-Montiel, Maria Jose and Bruno, Guillermina and Franco-Flores, Anna Kristina and Lépine, Sarah and Gursu, Lale and Haghi, Ghazal and Maussion, Gilles and Reintsch, Wolfgang E and Stefani, Fernando D and Anastasía, Agustín and Bisbal, Mariano and Gorostiza, Ezequiel Axel and Durcan, Thomas M and Unsain, Nicolás},
title = {{BetaII-spectrin gaps and patches emerge from the patterned assembly of the actin/spectrin membrane skeleton in human motor neuron axons}},
journal = {eLife},
year = {2026},
month = sep,
volume = {14},
pages = {RP108021},
publisher = {eLife Sciences Publications, Ltd},
issn = {2050-084X},
doi = {10.7554/elife.108021},
url = {https://doi.org/10.7554/elife.108021},
pmid = {42708447},
pmcid = {PMC13553066}
}

RIS

TY - JOUR
AU - Gazal, Nahir Guadalupe
AU - Castellanos-Montiel, Maria Jose
AU - Bruno, Guillermina
AU - Franco-Flores, Anna Kristina
AU - Lépine, Sarah
AU - Gursu, Lale
AU - Haghi, Ghazal
AU - Maussion, Gilles
AU - Reintsch, Wolfgang E
AU - Stefani, Fernando D
AU - Anastasía, Agustín
AU - Bisbal, Mariano
AU - Gorostiza, Ezequiel Axel
AU - Durcan, Thomas M
AU - Unsain, Nicolás
TI - BetaII-spectrin gaps and patches emerge from the patterned assembly of the actin/spectrin membrane skeleton in human motor neuron axons
T2 - eLife
J2 - Elife
PY - 2026
DA - 2026/09/08
VL - 14
SP - RP108021
SN - 2050-084X
PB - eLife Sciences Publications, Ltd
DO - 10.7554/elife.108021
UR - https://doi.org/10.7554/elife.108021
LA - en
ER -

CSL-JSON

{
"id": "10.7554/elife.108021",
"type": "article-journal",
"title": "BetaII-spectrin gaps and patches emerge from the patterned assembly of the actin/spectrin membrane skeleton in human motor neuron axons",
"container-title": "eLife",
"author": [
{
"family": "Gazal",
"given": "Nahir Guadalupe"
},
{
"family": "Castellanos-Montiel",
"given": "Maria Jose"
},
{
"family": "Bruno",
"given": "Guillermina"
},
{
"family": "Franco-Flores",
"given": "Anna Kristina"
},
{
"family": "Lépine",
"given": "Sarah"
},
{
"family": "Gursu",
"given": "Lale"
},
{
"family": "Haghi",
"given": "Ghazal"
},
{
"family": "Maussion",
"given": "Gilles"
},
{
"family": "Reintsch",
"given": "Wolfgang E"
},
{
"family": "Stefani",
"given": "Fernando D"
},
{
"family": "Anastasía",
"given": "Agustín"
},
{
"family": "Bisbal",
"given": "Mariano"
},
{
"family": "Gorostiza",
"given": "Ezequiel Axel"
},
{
"family": "Durcan",
"given": "Thomas M"
},
{
"family": "Unsain",
"given": "Nicolás"
}
],
"container-title-short": "Elife",
"volume": "14",
"page": "RP108021",
"DOI": "10.7554/elife.108021",
"PMID": "42708447",
"PMCID": "PMC13553066",
"ISSN": "2050-084X",
"publisher": "eLife Sciences Publications, Ltd",
"URL": "https://doi.org/10.7554/elife.108021",
"language": "en",
"issued": {
"date-parts": [
[
2026,
9,
8
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1016/j.cub.2026.03.053
External mechanical force drives axonal cytoskeletal rearrangements.
Journal: Current biology : CB
In common: cellular / molecular, 8 references
[2] doi:10.1038/s41467-026-73045-9 [code]
Aberration-aware 3D localization microscopy via self-supervised neural-physics learning.
Journal: Nature communications
In common: tifffile, scikit-image, Pillow, 3 other tools, cellular / molecular, 1 reference
[3] doi:10.1038/s41598-026-57519-w [code]
Automated segmentation of neurons and spinal cord structures in immunofluorescence images using SpineDL.
Journal: Scientific reports
In common: tifffile, scikit-image, Pillow, 3 other tools, mouse, 1 reference
[4] doi:10.1002/smll.74538
Stress-Adaptive Biomaterials With Tunable Yielding Architectures Regulate Organoid Morphogenesis.
Journal: Small (Weinheim an der Bergstrasse, Germany)
In common: 2 references, author Thomas M Durcan
[5] doi:10.1038/s42003-026-10063-9 [code]
Conserved Kir channel mechanisms governing intrinsic excitability in human and rodent parvalbumin neurons.
Journal: Communications biology
In common: tifffile, scikit-image, Pillow, 3 other tools, mouse, cellular / molecular
[6] doi:10.1038/s41586-026-10323-y [code]
Genetically encoded assembly recorder temporally resolves cellular history.
Journal: Nature
In common: tifffile, scikit-image, Pillow, 3 other tools, mouse, cellular / molecular
[7] doi:10.1371/journal.pcbi.1013441 [code]
Large vision model framework for automated C. elegans analysis: From static morphometry to dynamic neural activity.
Journal: PLoS computational biology
In common: tifffile, scikit-image, Pillow, 3 other tools, 1 reference
[8] doi:10.1016/j.isci.2026.116206 [code]
Gut distension evokes rapid neural dynamics in vagal and hindbrain populations of larval zebrafish.
Journal: iScience
In common: tifffile, scikit-image, Pillow, 3 other tools, 1 reference
[9] doi:10.1126/sciadv.aee9298 [code]
Synaptic zinc plasticity shapes adaptive and maladaptive cortical plasticity following cochlear injury.
Journal: Science advances
In common: tifffile, scikit-image, Pillow, 3 other tools, mouse, cellular / molecular
[10] doi:10.7554/elife.107635 [code]
Stable excitatory-inhibitory synapse balance despite dynamic turnover.
Journal: eLife
In common: tifffile, scikit-image, Pillow, 3 other tools, mouse, cellular / molecular

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.