Commit db29f28e authored by Vladimír Ulman's avatar Vladimír Ulman
Browse files

ADD, minLength: removing all filopodium voxels from a mask if it

                is not long enough or its tip is not displayed
parent e8c2de97
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,12 @@ filoAxisOrientedDensity 10
; (surface). This direction is orthogonal to filo axis.
; (surface). This direction is orthogonal to filo axis.
filoContourOrientedDensity	12
filoContourOrientedDensity	12


; Filopodium parameter:
; minimal length in microns of any filopodium (main filopodium or any branch)
; so that it is considered detectable and hence displayed in the
; ground truth final mask image -- shorter filopodia are not displayed
filoMinLength  0.6
		
; coarseness of initial Perlin noise in cell body (lower limit)
; coarseness of initial Perlin noise in cell body (lower limit)
coarsenessLower 1.0
coarsenessLower 1.0


+6 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,12 @@ filoAxisOrientedDensity 5
; (surface). This direction is orthogonal to filo axis.
; (surface). This direction is orthogonal to filo axis.
filoContourOrientedDensity	4
filoContourOrientedDensity	4


; Filopodium parameter:
; minimal length in microns of any filopodium (main filopodium or any branch)
; so that it is considered detectable and hence displayed in the
; ground truth final mask image -- shorter filopodia are not displayed
filoMinLength  0.6

; coarseness of initial Perlin noise in cell body (lower limit)
; coarseness of initial Perlin noise in cell body (lower limit)
coarsenessLower 1.0
coarsenessLower 1.0


+45 −14
Original line number Original line Diff line number Diff line
@@ -262,7 +262,7 @@ bool LoadNewMesh(const char* path,const int ID,const int fileNo,const bool keepT


	//first, obtain a fresh volumetric mesh of the cell body
	//first, obtain a fresh volumetric mesh of the cell body
	sprintf(fn,"%s/ID%d/ID%d_t%03d_nucleus.vtk",path,ID,ID,fileNo);
	sprintf(fn,"%s/ID%d/ID%d_t%03d_nucleus.vtk",path,ID,ID,fileNo);
	std::cout << "reading cell body: " << fn << "\n";
	std::cout << "___reading cell body: " << fn << "\n";


	//keep the volumetric configuration of the first load
	//keep the volumetric configuration of the first load
	bool saveAlsoTetrahedra=(mesh.GetVolIDsize() == 0);
	bool saveAlsoTetrahedra=(mesh.GetVolIDsize() == 0);
@@ -328,6 +328,13 @@ bool LoadNewMesh(const char* path,const int ID,const int fileNo,const bool keepT
				}
				}
				tipOffsets[idx].at((unsigned)fileNo)=(signed)iterTips->second;
				tipOffsets[idx].at((unsigned)fileNo)=(signed)iterTips->second;


				//debug report of calculated filopodia lengths
				const float l = mesh.calcFiloLength(iterTips->second);
				const int p = mesh.Ftree[iterTips->second].parent;
				std::cout << "filopodium ID " << idx << " (loaded as ID " << iterTips->second
				          << "): overall length: " << l << ", branches from: "
							 << (p>-1? p : 9999) << "\n";

				++iterTips;
				++iterTips;
			}
			}
		}
		}
@@ -352,9 +359,6 @@ bool LoadNewMesh(const char* path,const int ID,const int fileNo,const bool keepT
	return(true);
	return(true);
}
}


//TODO:
//pokud neni videt TIP nebo delka je mensi nez parametr, tak smazat vsechny pixely od tohot filopodia a do textaku -1

#define DO_PHASE_II_AND_III
#define DO_PHASE_II_AND_III
#define DO_ANISOTROPIC_OUTPUT
#define DO_ANISOTROPIC_OUTPUT
int RenderMesh(const char* path,const int ID,int fileNo)
int RenderMesh(const char* path,const int ID,int fileNo)
@@ -538,8 +542,6 @@ int RenderMesh(const char* path,const int ID,int fileNo)
	}
	}
 #endif
 #endif
#endif
#endif
	//save the mask image
	mask.SaveImage(fileName);


	//record voxel offsets within a mask image of all filopodia tips
	//record voxel offsets within a mask image of all filopodia tips
	const float xRes=mask.GetResolution().GetX();
	const float xRes=mask.GetResolution().GetX();
@@ -559,15 +561,41 @@ int RenderMesh(const char* path,const int ID,int fileNo)
			const unsigned int i=(unsigned)tipIter->second.at((unsigned)fileNo);
			const unsigned int i=(unsigned)tipIter->second.at((unsigned)fileNo);
			const Vector3FC& realPos=mesh.Ftree[i].fPoints[mesh.Ftree[i].segToPoint.back()];
			const Vector3FC& realPos=mesh.Ftree[i].fPoints[mesh.Ftree[i].segToPoint.back()];
			//get pixel coordinate
			//get pixel coordinate
			const size_t x=size_t((realPos.x-xOff) *xRes);
			const unsigned int x=(unsigned)int((realPos.x-xOff) *xRes);
			const size_t y=size_t((realPos.y-yOff) *yRes);
			const unsigned int y=(unsigned)int((realPos.y-yOff) *yRes);
			const size_t z=size_t((realPos.z-zOff) *zRes);
			const unsigned int z=(unsigned)int((realPos.z-zOff) *zRes);

			//  inside mask image?                          &&   is displayed color == the expected one?
			if (mask.Include((signed)x,(signed)y,(signed)z) && mask.GetVoxel(x,y,z) == tipIter->first)
			{
				//tip is visible, save its pixel offset
				tipIter->second.at((unsigned)fileNo)=(int)mask.GetIndex(x,y,z);
				tipIter->second.at((unsigned)fileNo)=(int)mask.GetIndex(x,y,z);


				//save also the micron coordinate at the corresponding place
				//save also the micron coordinate at the corresponding place
				//into the coordinate structure
				//into the coordinate structure
				tipCoords[tipIter->first].at((unsigned)fileNo)=realPos;
				tipCoords[tipIter->first].at((unsigned)fileNo)=realPos;
			}
			}
			else
			{
				//tip is not visible
				int removedCnt=0;

				//remove all voxels of this color (tipIter->first)
				i3d::GRAY16* p = mask.GetFirstVoxelAddr();
				i3d::GRAY16* const pL = p + mask.GetImageSize();
				while (p != pL)
				{
					if (*p == tipIter->first) { *p=0; ++removedCnt; }
					++p;
				}
				std::cout << "WARN: REMOVING " << removedCnt << " PIXELS of filopodium ID " << tipIter->first << "\n";

				// declare the filopodium is not present in this time point
				tipIter->second.at((unsigned)fileNo)=-1;

				//tipCoords is -1 by initialization
			}
		}
		++tipIter;
		++tipIter;
	}
	}


@@ -578,5 +606,8 @@ int RenderMesh(const char* path,const int ID,int fileNo)
	const size_t z=size_t((centreCoords[(unsigned)fileNo].z-zOff) *zRes);
	const size_t z=size_t((centreCoords[(unsigned)fileNo].z-zOff) *zRes);
	centreOffsets[(unsigned)fileNo]=(int)mask.GetIndex(x,y,z);
	centreOffsets[(unsigned)fileNo]=(int)mask.GetIndex(x,y,z);


	//save the mask image, finally (might have some pixels removed)
	mask.SaveImage(fileName);

	return(0);
	return(0);
}
}
+2 −2
Original line number Original line Diff line number Diff line
- TM nacita spatne geometrie filo-offspringu
- TM nacita spatne geometrie filo-offspringu
- zajistit konzistenci mezi textaky a maskou - viz zdrojaky, main_Generator, l. 356
+ zajistit konzistenci mezi textaky a maskou - viz zdrojaky, main_Generator, l. 356
  - zobrazovat filopodium jedine pokud: je videt tip AND delka filopodia vetsi nez parameter
  + zobrazovat filopodium jedine pokud: je videt tip AND delka filopodia vetsi nez parameter


+ textak podobny tip_realCOords (udaje v micrometrech, na 4. desetinna mista), stejna struktura, vypisuje aktualni delku filopodia (nebo -1 pokud neexistuje)
+ textak podobny tip_realCOords (udaje v micrometrech, na 4. desetinna mista), stejna struktura, vypisuje aktualni delku filopodia (nebo -1 pokud neexistuje)
  (Martin uz udelal, waiting for merge)
  (Martin uz udelal, waiting for merge)